aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_process_packet.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2022-12-10 19:49:11 +0100
committerGitHub <noreply@github.com>2022-12-10 19:49:11 +0100
commit48a7f6d487862a392bad65e9e2797e6c4874f8cb (patch)
tree62c6421f4286cab37d9f053f7e86cca77b3d8146 /fuzz/fuzz_process_packet.c
parent8c7071e040865b3b70b98ff8d8ad18c41f3fb74c (diff)
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)
Diffstat (limited to 'fuzz/fuzz_process_packet.c')
-rw-r--r--fuzz/fuzz_process_packet.c11
1 files changed, 3 insertions, 8 deletions
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 <stdint.h>
#include <stdio.h>
@@ -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);
}