From 4113cf749e9b6634f2b0b311bcd379ce065e7808 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 Merged-In: I64370af44a050bafea60ff1b0b2be18cc531480a (cherry picked from commit 1a6f6feff425edf6076269c0f971675fa41de56c) --- fastboot/fastboot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 827db9671..f8f7eb36e 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) {