diff options
| author | Vitaly Buka <vitalybuka@google.com> | 2019-04-05 20:17:03 +0000 |
|---|---|---|
| committer | Vitaly Buka <vitalybuka@google.com> | 2019-04-05 20:17:03 +0000 |
| commit | 3db6ad2bcfc5fb38343cfd7ce6eb56d9415e2b1e (patch) | |
| tree | aeaace02175721f5f948547d00487df853312a3b /compiler-rt/lib | |
| parent | 883ab235eea79198089319ccbd938ecf47f3c9dd (diff) | |
| download | bcm5719-llvm-3db6ad2bcfc5fb38343cfd7ce6eb56d9415e2b1e.tar.gz bcm5719-llvm-3db6ad2bcfc5fb38343cfd7ce6eb56d9415e2b1e.zip | |
Use binary write mode in WriteToFile function to avoid appended \r characters on Windows
Summary:
When using libfuzzer on Windows, in the contents of a crash sample, bytes that can be mistaken for a \n are replaced by a \r\n sequence. As a consequence, crashes are not reproducible. This patch will open files in binary mode to fix this issue. The patch does not affect POSIX systems.
Patch by tuktuk
Reviewers: kcc, vitalybuka
Reviewed By: vitalybuka
Subscribers: dexonsmith, jdoerfert, llvm-commits, #sanitizers
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D60008
llvm-svn: 357807
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerIO.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerIO.cpp b/compiler-rt/lib/fuzzer/FuzzerIO.cpp index 290112aa4b1..423ab4befba 100644 --- a/compiler-rt/lib/fuzzer/FuzzerIO.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerIO.cpp @@ -62,7 +62,7 @@ void CopyFileToErr(const std::string &Path) { void WriteToFile(const Unit &U, const std::string &Path) { // Use raw C interface because this function may be called from a sig handler. - FILE *Out = fopen(Path.c_str(), "w"); + FILE *Out = fopen(Path.c_str(), "wb"); if (!Out) return; fwrite(U.data(), sizeof(U[0]), U.size(), Out); fclose(Out); |

