about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2023-04-13 15:32:06 +0200
committervanhauser-thc <vh@thc.org>2023-04-13 15:32:06 +0200
commit2adf5aac0fcf9b9263bfe3dd93e4d860e3668ae4 (patch)
treee2327270c62502593cd42e919f07fbe8b3c3559d
parentf756734ad2782c3ed56feadb4b7b23fc82a7a968 (diff)
downloadafl++-2adf5aac0fcf9b9263bfe3dd93e4d860e3668ae4.tar.gz
libfuzzer driver nits
-rw-r--r--dynamic_list.txt1
-rw-r--r--utils/aflpp_driver/aflpp_driver.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/dynamic_list.txt b/dynamic_list.txt
index d06eae4e..50c0c6b8 100644
--- a/dynamic_list.txt
+++ b/dynamic_list.txt
@@ -54,4 +54,5 @@
   "__sanitizer_cov_trace_pc_guard";
   "__sanitizer_cov_trace_pc_guard_init";
   "__sanitizer_cov_trace_switch";
+  "LLVMFuzzerTestOneInput";
 };
diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c
index ec304c8c..19f0d9da 100644
--- a/utils/aflpp_driver/aflpp_driver.c
+++ b/utils/aflpp_driver/aflpp_driver.c
@@ -33,6 +33,11 @@ $ afl-fuzz -i in -o out -- ./test_fuzzer
 
 */
 
+#ifdef __cplusplus
+extern "C" {
+
+#endif
+
 #include <assert.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -260,6 +265,13 @@ static int ExecuteFilesOnyByOne(int argc, char **argv,
 
 __attribute__((weak)) int main(int argc, char **argv) {
 
+  if (!LLVMFuzzerTestOneInput) {
+
+    fprintf(stderr, "Error: function LLVMFuzzerTestOneInput() not found!\n");
+    abort();
+
+  }
+
   if (argc < 2 || strncmp(argv[1], "-h", 2) == 0)
     printf(
         "============================== INFO ================================\n"
@@ -409,3 +421,9 @@ __attribute__((weak)) int LLVMFuzzerRunDriver(
 
 }
 
+#ifdef __cplusplus
+
+}
+
+#endif
+