[PATCH] D41193: [libFuzzer] Add dummy call of LLVMFuzzerTestOneInput to afl_driver.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 14:03:25 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT320643: [libFuzzer] Add dummy call of LLVMFuzzerTestOneInput to afl_driver. (authored by morehouse, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41193?vs=126812&id=126839#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D41193

Files:
  lib/fuzzer/afl/afl_driver.cpp


Index: lib/fuzzer/afl/afl_driver.cpp
===================================================================
--- lib/fuzzer/afl/afl_driver.cpp
+++ lib/fuzzer/afl/afl_driver.cpp
@@ -88,7 +88,7 @@
 // to the file as well, if the error occurs after the duplication is performed.
 #define CHECK_ERROR(cond, error_message)                                       \
   if (!(cond)) {                                                               \
-    fprintf(stderr, (error_message));                                          \
+    fprintf(stderr, "%s\n", (error_message));                                  \
     abort();                                                                   \
   }
 
@@ -308,6 +308,12 @@
     return ExecuteFilesOnyByOne(argc, argv);
 
   assert(N > 0);
+
+  // Call LLVMFuzzerTestOneInput here so that coverage caused by initialization
+  // on the first execution of LLVMFuzzerTestOneInput is ignored.
+  uint8_t dummy_input[1] = {0};
+  LLVMFuzzerTestOneInput(dummy_input, 1);
+
   time_t unit_time_secs;
   int num_runs = 0;
   while (__afl_persistent_loop(N)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41193.126839.patch
Type: text/x-patch
Size: 1089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/9880222b/attachment.bin>


More information about the llvm-commits mailing list