[fuzzer] Read files as binary
Summary: Read corpus files as binary to avoid automatic conversions
Reviewers: Dor1s, morehouse
Reviewed By: Dor1s, morehouse
Differential Revision: https://reviews.llvm.org/D54180
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer@346279 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/FuzzerIO.cpp b/FuzzerIO.cpp
index dac5ec6..c4c31e8 100644
--- a/FuzzerIO.cpp
+++ b/FuzzerIO.cpp
@@ -31,7 +31,7 @@
}
Unit FileToVector(const std::string &Path, size_t MaxSize, bool ExitOnError) {
- std::ifstream T(Path);
+ std::ifstream T(Path, std::ios::binary);
if (ExitOnError && !T) {
Printf("No such directory: %s; exiting\n", Path.c_str());
exit(1);
@@ -51,7 +51,7 @@
}
std::string FileToString(const std::string &Path) {
- std::ifstream T(Path);
+ std::ifstream T(Path, std::ios::binary);
return std::string((std::istreambuf_iterator<char>(T)),
std::istreambuf_iterator<char>());
}