]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fuzz: enable AFLFUZZ_PERSISTANT_MODE for libfuzzer targets
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 28 Feb 2020 08:41:52 +0000 (09:41 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 20 Mar 2020 12:21:52 +0000 (13:21 +0100)
src/tests/fuzz/onefile.c

index 8ea7ac907d0b4d32737e424536d721dbf6bc58b6..e5d34ab182dec23c611a168b9dfe0b203349e587 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include "config.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
 
@@ -13,6 +14,10 @@ int main(int argc, char** argv)
     if (argc != 2) {
         return 1;
     }
+#ifdef AFLFUZZ_PERSISTANT_MODE
+    while (__AFL_LOOP(1000)) {
+#endif /* AFLFUZZ_PERSISTANT_MODE */
+
     //opens the file, get its size, and reads it into a buffer
     fp = fopen(argv[1], "rb");
     if (fp == NULL) {
@@ -46,5 +51,10 @@ int main(int argc, char** argv)
     LLVMFuzzerTestOneInput(data, size);
     free(data);
     fclose(fp);
+#ifdef AFLFUZZ_PERSISTANT_MODE
+    }
+#endif /* AFLFUZZ_PERSISTANT_MODE */
+
     return 0;
 }
+