aboutsummaryrefslogtreecommitdiff
path: root/examples/aflpp_driver
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-14 13:23:14 +0200
committerGitHub <noreply@github.com>2020-08-14 13:23:14 +0200
commita7537b5511ad767d2240cf2dc6d3e261daa676f9 (patch)
tree2cd8418efff844e634425e050ef716301adfd84b /examples/aflpp_driver
parent15e799f7ae666418e75c6a79db833c5316b21f97 (diff)
parent83281503b3f1d4109c6f7a6af62a2133d55f1150 (diff)
downloadafl++-a7537b5511ad767d2240cf2dc6d3e261daa676f9.tar.gz
Merge branch 'debug' into dev
Diffstat (limited to 'examples/aflpp_driver')
-rw-r--r--examples/aflpp_driver/aflpp_driver.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/examples/aflpp_driver/aflpp_driver.c b/examples/aflpp_driver/aflpp_driver.c
index b764338e..8e0b554a 100644
--- a/examples/aflpp_driver/aflpp_driver.c
+++ b/examples/aflpp_driver/aflpp_driver.c
@@ -106,10 +106,7 @@ If 1, close stdout at startup. If 2 close stderr; if 3 close both.
#error "Support for your platform has not been implemented"
#endif
-int __afl_sharedmem_fuzzing = 1;
-extern unsigned int * __afl_fuzz_len;
-extern unsigned char *__afl_fuzz_ptr;
-// extern struct cmp_map *__afl_cmp_map;
+int __afl_sharedmem_fuzzing = 0;
// libFuzzer interface is thin, so we don't include any libFuzzer headers.
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
@@ -275,6 +272,7 @@ int main(int argc, char **argv) {
// Do any other expensive one-time initialization here.
uint8_t dummy_input[64] = {0};
+ uint8_t buf[1024000];
memcpy(dummy_input, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT));
memcpy(dummy_input + 32, (void *)AFL_DEFER_FORKSVR,
sizeof(AFL_DEFER_FORKSVR));
@@ -285,16 +283,24 @@ int main(int argc, char **argv) {
printf("WARNING: using the deprecated call style `%s %d`\n", argv[0], N);
else if (argc > 1) {
- __afl_sharedmem_fuzzing = 0;
- __afl_manual_init();
+ if (!getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) {
+
+ __afl_manual_init();
+
+ }
+
return ExecuteFilesOnyByOne(argc, argv);
}
assert(N > 0);
- // if (!getenv("AFL_DRIVER_DONT_DEFER"))
- __afl_manual_init();
+ if (!getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) {
+
+ fprintf(stderr, "performing manual init\n");
+ __afl_manual_init();
+
+ }
// Call LLVMFuzzerTestOneInput here so that coverage caused by initialization
// on the first execution of LLVMFuzzerTestOneInput is ignored.
@@ -303,25 +309,13 @@ int main(int argc, char **argv) {
int num_runs = 0;
while (__afl_persistent_loop(N)) {
-#ifdef _DEBUG
- fprintf(stderr, "CLIENT crc: %016llx len: %u\n",
- hash64(__afl_fuzz_ptr, *__afl_fuzz_len, 0xa5b35705),
- *__afl_fuzz_len);
- fprintf(stderr, "RECV:");
- for (int i = 0; i < *__afl_fuzz_len; i++)
- fprintf(stderr, "%02x", __afl_fuzz_ptr[i]);
- fprintf(stderr, "\n");
-#endif
- if (*__afl_fuzz_len) {
-
- num_runs++;
- LLVMFuzzerTestOneInput(__afl_fuzz_ptr, *__afl_fuzz_len);
+ ssize_t r = read(0, buf, sizeof(buf));
- }
+ if (r > 0) { LLVMFuzzerTestOneInput(buf, r); }
}
- printf("%s: successfully executed %d input(s)\n", argv[0], num_runs);
+ printf("%s: successfully executed input(s)\n", argv[0]);
}