From da551c753f49ded690d60d5dbe81ad35c4eaefb8 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sat, 18 Feb 2017 02:52:38 +0100 Subject: [PATCH] fuzzing: Speed up afl using persistent mode (in proccess fuzzing) --- fuzzing/CMakeLists.txt | 2 ++ fuzzing/afl.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt index d39a652..fdd7126 100644 --- a/fuzzing/CMakeLists.txt +++ b/fuzzing/CMakeLists.txt @@ -18,6 +18,8 @@ if (ENABLE_FUZZING) set(fuzz_print_parameter "yes") endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") + add_custom_target(afl COMMAND "${AFL_FUZZ}" -i "${CMAKE_CURRENT_SOURCE_DIR}/inputs" -o "${CMAKE_CURRENT_BINARY_DIR}/findings" -x "${CMAKE_CURRENT_SOURCE_DIR}/json.dict" -- "${CMAKE_CURRENT_BINARY_DIR}/afl-main" "@@" "${fuzz_print_parameter}" DEPENDS afl-main) diff --git a/fuzzing/afl.c b/fuzzing/afl.c index 59bbca7..af5945d 100644 --- a/fuzzing/afl.c +++ b/fuzzing/afl.c @@ -87,7 +87,7 @@ int main(int argc, char** argv) const char *filename = NULL; cJSON *item = NULL; char *json = NULL; - int status = EXIT_SUCCESS; + int status; char *printed_json = NULL; if ((argc < 2) || (argc > 3)) @@ -100,6 +100,12 @@ int main(int argc, char** argv) filename = argv[1]; +#if __AFL_HAVE_MANUAL_CONTROL + while (__AFL_LOOP(1000)) + { +#endif + status = EXIT_SUCCESS; + json = read_file(filename); if ((json == NULL) || (json[0] == '\0') || (json[1] == '\0')) { @@ -149,15 +155,21 @@ cleanup: if (item != NULL) { cJSON_Delete(item); + item = NULL; } if (json != NULL) { free(json); + json = NULL; } if (printed_json != NULL) { free(printed_json); + printed_json = NULL; } +#if __AFL_HAVE_MANUAL_CONTROL + } +#endif return status; }