about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-09-11 08:56:28 +0200
committervan Hauser <vh@thc.org>2020-09-11 08:56:28 +0200
commit862b6d0382a132cc5338cfdcdc2c30c2cd8d578b (patch)
treed324cfafb78efa62de6f65656f7a196ab7e6ccb1
parent543765bc0df02ef7d2db3690383a857ca7963286 (diff)
downloadafl++-862b6d0382a132cc5338cfdcdc2c30c2cd8d578b.tar.gz
fix for afl-compiler-rt to only send dictionary data if there is some
-rw-r--r--custom_mutators/libfuzzer/FuzzerDriver.cpp2
-rw-r--r--custom_mutators/libfuzzer/FuzzerExtFunctionsDlsym.cpp4
-rw-r--r--custom_mutators/libfuzzer/FuzzerExtFunctionsWeak.cpp7
-rw-r--r--custom_mutators/libfuzzer/FuzzerExtFunctionsWindows.cpp23
-rw-r--r--instrumentation/afl-compiler-rt.o.c6
5 files changed, 22 insertions, 20 deletions
diff --git a/custom_mutators/libfuzzer/FuzzerDriver.cpp b/custom_mutators/libfuzzer/FuzzerDriver.cpp
index 9a0a32b0..6468a02e 100644
--- a/custom_mutators/libfuzzer/FuzzerDriver.cpp
+++ b/custom_mutators/libfuzzer/FuzzerDriver.cpp
@@ -77,7 +77,7 @@ struct {
 } Flags;
 
 static const FlagDescription FlagDescriptions[]{
-\
+
 #define FUZZER_DEPRECATED_FLAG(Name) \
   {#Name, "Deprecated; don't use", 0, nullptr, nullptr, nullptr},
 #define FUZZER_FLAG_INT(Name, Default, Description) \
diff --git a/custom_mutators/libfuzzer/FuzzerExtFunctionsDlsym.cpp b/custom_mutators/libfuzzer/FuzzerExtFunctionsDlsym.cpp
index 8009b237..4a4d58fc 100644
--- a/custom_mutators/libfuzzer/FuzzerExtFunctionsDlsym.cpp
+++ b/custom_mutators/libfuzzer/FuzzerExtFunctionsDlsym.cpp
@@ -45,8 +45,8 @@ namespace fuzzer {
 
 ExternalFunctions::ExternalFunctions() {
 \
-  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
-    this->NAME = GetFnPtr<decltype(ExternalFunctions::NAME)>(#NAME, WARN)
+  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) this->NAME =
+      GetFnPtr < decltype(ExternalFunctions::NAME)>(#NAME, WARN)
 
   #include "FuzzerExtFunctions.def"
 
diff --git a/custom_mutators/libfuzzer/FuzzerExtFunctionsWeak.cpp b/custom_mutators/libfuzzer/FuzzerExtFunctionsWeak.cpp
index c7a1d05e..bbd8f3ba 100644
--- a/custom_mutators/libfuzzer/FuzzerExtFunctionsWeak.cpp
+++ b/custom_mutators/libfuzzer/FuzzerExtFunctionsWeak.cpp
@@ -46,10 +46,9 @@ namespace fuzzer {
 
 ExternalFunctions::ExternalFunctions() {
 \
-  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                         \
-    this->NAME = ::NAME;                                                      \
-    CheckFnPtr(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(::NAME)), \
-               #NAME, WARN);
+  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) this->NAME = ::NAME;
+  CheckFnPtr(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(::NAME)),
+             #NAME, WARN);
 
   #include "FuzzerExtFunctions.def"
 
diff --git a/custom_mutators/libfuzzer/FuzzerExtFunctionsWindows.cpp b/custom_mutators/libfuzzer/FuzzerExtFunctionsWindows.cpp
index a727220a..d79421cd 100644
--- a/custom_mutators/libfuzzer/FuzzerExtFunctionsWindows.cpp
+++ b/custom_mutators/libfuzzer/FuzzerExtFunctionsWindows.cpp
@@ -45,15 +45,16 @@ using namespace fuzzer;
   #endif  // LIBFUZZER_MSVC
 
 extern "C" {
-\
-  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)         \
-    RETURN_TYPE NAME##Def FUNC_SIG {                          \
-                                                              \
-      Printf("ERROR: Function \"%s\" not defined.\n", #NAME); \
-      exit(1);                                                \
-                                                              \
-    }                                                         \
-    EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG
+
+#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)
+    RETURN_TYPE NAME##Def FUNC_SIG {
+
+  Printf("ERROR: Function \"%s\" not defined.\n", #NAME);
+  exit(1);
+
+}
+
+EXTERNAL_FUNC(NAME, NAME##Def) RETURN_TYPE NAME FUNC_SIG
 
   #include "FuzzerExtFunctions.def"
 
@@ -80,8 +81,8 @@ namespace fuzzer {
 
 ExternalFunctions::ExternalFunctions() {
 \
-  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
-    this->NAME = GetFnPtr<decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN);
+  #define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) this->NAME =
+      GetFnPtr < decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN);
 
   #include "FuzzerExtFunctions.def"
 
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index 0e8b97a2..209cc726 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -469,7 +469,8 @@ static void __afl_start_snapshots(void) {
     }
 
     if ((was_killed & (FS_OPT_ENABLED | FS_OPT_AUTODICT)) ==
-        (FS_OPT_ENABLED | FS_OPT_AUTODICT)) {
+            (FS_OPT_ENABLED | FS_OPT_AUTODICT) &&
+        __afl_dictionary_len && __afl_dictionary) {
 
       // great lets pass the dictionary through the forkserver FD
       u32 len = __afl_dictionary_len, offset = 0;
@@ -681,7 +682,8 @@ static void __afl_start_forkserver(void) {
     }
 
     if ((was_killed & (FS_OPT_ENABLED | FS_OPT_AUTODICT)) ==
-        (FS_OPT_ENABLED | FS_OPT_AUTODICT)) {
+            (FS_OPT_ENABLED | FS_OPT_AUTODICT) &&
+        __afl_dictionary_len && __afl_dictionary) {
 
       // great lets pass the dictionary through the forkserver FD
       u32 len = __afl_dictionary_len, offset = 0;