From 48a7f6d487862a392bad65e9e2797e6c4874f8cb Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Sat, 10 Dec 2022 19:49:11 +0100 Subject: fuzz: some enhancements (#1827) Load some custom configuration (like in the unit tests) and factorize some (fuzzing) common code. There is no way to pass file paths to the fuzzers as parameters. The safe solution seems to be to load them from the process working dir. Anyway, missing file is not a blocking error. Remove some dead code (found looking at the coverage report) --- fuzz/fuzz_process_packet.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'fuzz/fuzz_process_packet.c') diff --git a/fuzz/fuzz_process_packet.c b/fuzz/fuzz_process_packet.c index f41a49701..7376f4fd8 100644 --- a/fuzz/fuzz_process_packet.c +++ b/fuzz/fuzz_process_packet.c @@ -1,4 +1,5 @@ #include "ndpi_api.h" +#include "fuzz_common_code.h" #include #include @@ -11,14 +12,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { uint8_t protocol_was_guessed; if (ndpi_info_mod == NULL) { - ndpi_info_mod = ndpi_init_detection_module(ndpi_enable_ja3_plus); - NDPI_PROTOCOL_BITMASK all, debug_bitmask; - NDPI_BITMASK_SET_ALL(all); - NDPI_BITMASK_SET_ALL(debug_bitmask); - ndpi_set_protocol_detection_bitmask2(ndpi_info_mod, &all); - ndpi_set_log_level(ndpi_info_mod, 4); - ndpi_set_debug_bitmask(ndpi_info_mod, debug_bitmask); - ndpi_finalize_initialization(ndpi_info_mod); + fuzz_init_detection_module(&ndpi_info_mod, 0); + ndpi_init_serializer(&json_serializer, ndpi_serialization_format_json); ndpi_init_serializer(&csv_serializer, ndpi_serialization_format_csv); } -- cgit v1.2.3