Open image files in binary mode

This is required for read() to function correctly
in Windows since it behaves differently in text mode and
binary mode and may cause unpredictable behavior depending
on the contents of the image file.

Bug: 129281908
Test: fastboot.exe flashall
Change-Id: I64370af44a050bafea60ff1b0b2be18cc531480a
Merged-In: I64370af44a050bafea60ff1b0b2be18cc531480a
(cherry picked from commit 1a6f6feff4)
This commit is contained in:
Hridya Valsaraju 2019-04-03 17:57:00 -07:00
parent 20b0bd9ca4
commit 4113cf749e

View file

@ -1407,7 +1407,7 @@ bool LocalImageSource::ReadFile(const std::string& name, std::vector<char>* out)
int LocalImageSource::OpenFile(const std::string& name) const {
auto path = find_item_given_name(name);
return open(path.c_str(), O_RDONLY);
return open(path.c_str(), O_RDONLY | O_BINARY);
}
static void do_flashall(const std::string& slot_override, bool skip_secondary, bool wipe) {