[PATCH] D60008: Use binary write mode in WriteToFile function to avoid appended \r characters on Windows
tuktuk via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 12:40:46 PDT 2019
tuktuk created this revision.
tuktuk added a reviewer: kcc.
Herald added projects: LLVM, Sanitizers.
Herald added subscribers: Sanitizers, llvm-commits.
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.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D60008
Files:
lib/fuzzer/FuzzerIO.cpp
Index: lib/fuzzer/FuzzerIO.cpp
===================================================================
--- lib/fuzzer/FuzzerIO.cpp
+++ lib/fuzzer/FuzzerIO.cpp
@@ -62,7 +62,7 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60008.192890.patch
Type: text/x-patch
Size: 487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190329/3c92ec0c/attachment.bin>
More information about the llvm-commits
mailing list