about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-12-17 09:42:05 +0100
committervanhauser-thc <vh@thc.org>2021-12-17 09:42:05 +0100
commitb3a0ecfd48d38c5dec331e8f059932ff7f6b39a0 (patch)
tree0e911c5d81d9e4e6688ace5b5ae63755a86f2093
parent641a943d95436d9e9f4312ae06c74c54624f084d (diff)
downloadafl++-b3a0ecfd48d38c5dec331e8f059932ff7f6b39a0.tar.gz
allow ignore dlopen issues
-rw-r--r--include/envs.h3
-rw-r--r--instrumentation/afl-compiler-rt.o.c28
2 files changed, 23 insertions, 8 deletions
diff --git a/include/envs.h b/include/envs.h
index a3ba5e88..adb1b67e 100644
--- a/include/envs.h
+++ b/include/envs.h
@@ -94,8 +94,8 @@ static char *afl_environment_variables[] = {
     "AFL_FORKSRV_INIT_TMOUT",
     "AFL_HARDEN",
     "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES",
-    "AFL_IGNORE_UNKNOWN_ENVS",
     "AFL_IGNORE_PROBLEMS",
+    "AFL_IGNORE_UNKNOWN_ENVS",
     "AFL_IMPORT_FIRST",
     "AFL_INST_LIBS",
     "AFL_INST_RATIO",
@@ -193,6 +193,7 @@ static char *afl_environment_variables[] = {
     "AFL_SKIP_BIN_CHECK",
     "AFL_SKIP_CPUFREQ",
     "AFL_SKIP_CRASHES",
+    "AFL_SKIP_OSSFUZZ",
     "AFL_STATSD",
     "AFL_STATSD_HOST",
     "AFL_STATSD_PORT",
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index 20f325f3..fe701b7a 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -1421,11 +1421,25 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
   // we have a problem as we cannot increase the coverage map anymore.
   if (__afl_already_initialized_forkserver) {
 
-    fprintf(stderr,
-            "[-] FATAL: forkserver is already up, but an instrumented dlopen() "
-            "library loaded afterwards. You must AFL_PRELOAD such libraries to "
-            "be able to fuzz them or LD_PRELOAD to run outside of afl-fuzz.\n");
-    abort();
+    if (!getenv("AFL_IGNORE_PROBLEMS")) {
+
+      fprintf(
+          stderr,
+          "[-] FATAL: forkserver is already up, but an instrumented dlopen() "
+          "library loaded afterwards. You must AFL_PRELOAD such libraries to "
+          "be able to fuzz them or LD_PRELOAD to run outside of afl-fuzz.\n"
+          "To ignore this set AFL_IGNORE_PROBLEMS=1.\n");
+      abort();
+
+    } else {
+
+      while (start < stop) {
+
+        *(start++) = 4;
+
+      }
+
+    }
 
   }
 
@@ -1462,7 +1476,7 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
         if (R(100) < inst_ratio)
           *start = ++__afl_final_loc % __afl_map_size;
         else
-          *start = 0;
+          *start = 4;
 
         start++;
 
@@ -1487,7 +1501,7 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
     if (R(100) < inst_ratio)
       *start = ++__afl_final_loc;
     else
-      *start = 0;
+      *start = 4;
 
     start++;