[PATCH] D27922: [libFuzzer] Diff 27 - Update afl driver to use std::istream::read() instead of posix read().

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 08:40:08 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/D27922

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
@@ -51,6 +51,7 @@
 */
 #include <assert.h>
 #include <chrono>
+#include <iostream>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -264,7 +265,8 @@
   assert(N > 0);
   int num_runs = 0;
   while (__afl_persistent_loop(N)) {
-    ssize_t n_read = read(0, AflInputBuf, kMaxAflInputSize);
+    std::cin.read((char*) AflInputBuf, kMaxAflInputSize);
+    std::streamsize n_read = std::cin.gcount();
     if (n_read > 0) {
       // Copy AflInputBuf into a separate buffer to let asan find buffer
       // overflows. Don't use unique_ptr/etc to avoid extra dependencies.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27922.81957.patch
Type: text/x-patch
Size: 757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161219/4feae1e2/attachment.bin>


More information about the llvm-commits mailing list