From: Philippe Antoine Date: Fri, 28 Feb 2020 08:41:52 +0000 (+0100) Subject: fuzz: enable AFLFUZZ_PERSISTANT_MODE for libfuzzer targets X-Git-Tag: suricata-6.0.0-beta1~613 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eddaa038ea453787f213df11de3c5482c3d7feb;p=thirdparty%2Fsuricata.git fuzz: enable AFLFUZZ_PERSISTANT_MODE for libfuzzer targets --- diff --git a/src/tests/fuzz/onefile.c b/src/tests/fuzz/onefile.c index 8ea7ac907d..e5d34ab182 100644 --- a/src/tests/fuzz/onefile.c +++ b/src/tests/fuzz/onefile.c @@ -1,6 +1,7 @@ #include #include #include +#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; } +