[PATCH] D27954: [libFuzzer] Diff 42 - [FuzzerSupport] Use Printf() from FuzzerSupport instead of fprintf().

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 14:25:17 PST 2016


mpividori created this revision.
mpividori added reviewers: kcc, zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D27954

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
@@ -50,6 +50,7 @@
 
 */
 #include "../Support/Util.h"
+#include "../Support/UtilIO.h"
 #include <assert.h>
 #include <chrono>
 #include <iostream>
@@ -67,7 +68,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));                                          \
+    fuzzer::Printf(error_message);                                             \
     abort();                                                                   \
   }
 
@@ -195,24 +196,23 @@
       freopen(stderr_duplicate_filename, "a+", stderr);
 
   if (!stderr_duplicate_stream) {
-    fprintf(
-        stderr,
+    fuzzer::Printf(
         "Failed to duplicate stderr to AFL_DRIVER_STDERR_DUPLICATE_FILENAME");
     abort();
   }
 }
 
 int main(int argc, char **argv) {
-  fprintf(stderr, "======================= INFO =========================\n"
-                  "This binary is built for AFL-fuzz.\n"
-                  "To run the target function on a single input execute this:\n"
-                  "  %s < INPUT_FILE\n"
-                  "To run the fuzzing execute this:\n"
-                  "  afl-fuzz [afl-flags] %s [N] "
-                  "-- run N fuzzing iterations before "
-                  "re-spawning the process (default: 1000)\n"
-                  "======================================================\n",
-          argv[0], argv[0]);
+  fuzzer::Printf("======================= INFO =========================\n"
+         "This binary is built for AFL-fuzz.\n"
+         "To run the target function on a single input execute this:\n"
+         "  %s < INPUT_FILE\n"
+         "To run the fuzzing execute this:\n"
+         "  afl-fuzz [afl-flags] %s [N] "
+         "-- run N fuzzing iterations before "
+         "re-spawning the process (default: 1000)\n"
+         "======================================================\n",
+         argv[0], argv[0]);
   if (LLVMFuzzerInitialize)
     LLVMFuzzerInitialize(&argc, &argv);
   // Do any other expensive one-time initialization here.
@@ -251,5 +251,5 @@
       delete[] copy;
     }
   }
-  fprintf(stderr, "%s: successfully executed %d input(s)\n", argv[0], num_runs);
+  fuzzer::Printf("%s: successfully executed %d input(s)\n", argv[0], num_runs);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27954.82018.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161219/fda9af8f/attachment.bin>


More information about the llvm-commits mailing list