summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatt Morehouse <mascasa@google.com>2017-12-13 22:02:44 +0000
committerMatt Morehouse <mascasa@google.com>2017-12-13 22:02:44 +0000
commit589f4670016442ce76b8e8ff65c2ab690cb6d511 (patch)
treecdbaaade975bee903d85528300dc943bbf2bf3ef /lib
parente48d698dc9f9532fb51a8eff9558176c60da4300 (diff)
[libFuzzer] Add dummy call of LLVMFuzzerTestOneInput to afl_driver.
Summary: Add dummy call of LLVMFuzzerTestOneInput to afl_driver before it starts executing on actual inputs. Do this so that first time initialization performed by LLVMFuzzerTestOneInput is not considered code covered by a particular input. Patch By: metzman Reviewers: kcc, morehouse Reviewed By: kcc Subscribers: llvm-commits, Sanitizers Differential Revision: https://reviews.llvm.org/D41193 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/fuzzer/afl/afl_driver.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/fuzzer/afl/afl_driver.cpp b/lib/fuzzer/afl/afl_driver.cpp
index f10247947..bbe5be795 100644
--- a/lib/fuzzer/afl/afl_driver.cpp
+++ b/lib/fuzzer/afl/afl_driver.cpp
@@ -88,7 +88,7 @@ statistics from the file. If that fails then the process will quit.
// 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 @@ int main(int argc, char **argv) {
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)) {