about summary refs log tree commit diff
path: root/examples/aflpp_driver/aflpp_driver.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-07 11:10:17 +0200
committervan Hauser <vh@thc.org>2020-08-07 11:10:17 +0200
commit5b0616614433b87b96bc72951b9a0828974e8a4e (patch)
tree06cd6cb019af7eff39c7778bab7ad4c5a000a571 /examples/aflpp_driver/aflpp_driver.c
parenta0fab35bbf8454c0421f7c5c5e6076f0e05b67a7 (diff)
downloadafl++-5b0616614433b87b96bc72951b9a0828974e8a4e.tar.gz
reverse cmplog temps
Diffstat (limited to 'examples/aflpp_driver/aflpp_driver.c')
-rw-r--r--examples/aflpp_driver/aflpp_driver.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/aflpp_driver/aflpp_driver.c b/examples/aflpp_driver/aflpp_driver.c
index 90f9cf99..7d388799 100644
--- a/examples/aflpp_driver/aflpp_driver.c
+++ b/examples/aflpp_driver/aflpp_driver.c
@@ -106,11 +106,11 @@ 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 unsigned char * __afl_area_ptr;
-extern struct cmp_map *__afl_cmp_map;
+int                   __afl_sharedmem_fuzzing = 1;
+extern unsigned int * __afl_fuzz_len;
+extern unsigned char *__afl_fuzz_ptr;
+extern unsigned char *__afl_area_ptr;
+// extern struct cmp_map *__afl_cmp_map;
 
 // libFuzzer interface is thin, so we don't include any libFuzzer headers.
 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
@@ -248,8 +248,9 @@ static int ExecuteFilesOnyByOne(int argc, char **argv) {
 
 }
 
-__attribute__((constructor(10))) void __afl_protect(void) {
+__attribute__((constructor(1))) void __afl_protect(void) {
 
+  setenv("__AFL_DEFER_FORKSRV", "1", 1);
   __afl_area_ptr = (unsigned char *)mmap(
       (void *)0x10000, MAX_DUMMY_SIZE, PROT_READ | PROT_WRITE,
       MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
@@ -261,7 +262,7 @@ __attribute__((constructor(10))) void __afl_protect(void) {
     __afl_area_ptr =
         (unsigned char *)mmap(NULL, MAX_DUMMY_SIZE, PROT_READ | PROT_WRITE,
                               MAP_SHARED | MAP_ANONYMOUS, -1, 0);
-  __afl_cmp_map = (struct cmp_map *)__afl_area_ptr;
+  // __afl_cmp_map = (struct cmp_map *)__afl_area_ptr;
 
 }
 
@@ -305,14 +306,11 @@ int main(int argc, char **argv) {
     printf("WARNING: using the deprecated call style `%s %d`\n", argv[0], N);
   else if (argc > 1) {
 
-    //    if (!getenv("AFL_DRIVER_DONT_DEFER")) {
-
     __afl_sharedmem_fuzzing = 0;
-    munmap(__afl_area_ptr, MAX_DUMMY_SIZE);
+    munmap(__afl_area_ptr, MAX_DUMMY_SIZE);  // we need to free 0x10000
+    __afl_area_ptr = NULL;
     __afl_manual_init();
-    //    }
     return ExecuteFilesOnyByOne(argc, argv);
-    exit(0);
 
   }
 
@@ -320,6 +318,7 @@ int main(int argc, char **argv) {
 
   //  if (!getenv("AFL_DRIVER_DONT_DEFER"))
   munmap(__afl_area_ptr, MAX_DUMMY_SIZE);
+  __afl_area_ptr = NULL;
   __afl_manual_init();
 
   // Call LLVMFuzzerTestOneInput here so that coverage caused by initialization