From 1a6f6feff425edf6076269c0f971675fa41de56c Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Wed, 3 Apr 2019 17:57:00 -0700 Subject: [PATCH] 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 --- fastboot/fastboot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 4cdd8bcd9..cf8573ba6 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1407,7 +1407,7 @@ bool LocalImageSource::ReadFile(const std::string& name, std::vector* 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) {