From 5e8c1ebbb7f67033916ed4878cd6c2a662073898 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Fri, 20 Jan 2023 14:27:33 +0100 Subject: fuzz: fix memory allocation failure logic (#1867) We *do* want to have some allocation errors. Fix some related bugs Fix: 29be01ef --- fuzz/fuzz_alg_hll.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'fuzz/fuzz_alg_hll.cpp') diff --git a/fuzz/fuzz_alg_hll.cpp b/fuzz/fuzz_alg_hll.cpp index 85733da63..617968dfd 100644 --- a/fuzz/fuzz_alg_hll.cpp +++ b/fuzz/fuzz_alg_hll.cpp @@ -5,8 +5,6 @@ #include #include "fuzzer/FuzzedDataProvider.h" -struct ndpi_detection_module_struct *ndpi_info_mod = NULL; - extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { FuzzedDataProvider fuzzed_data(data, size); u_int16_t i, num_iteration; @@ -16,11 +14,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if(fuzzed_data.remaining_bytes() < 2048) return -1; - /* We don't really need the detection module, but this way we can enable - memory allocation failures */ - if (ndpi_info_mod == NULL) { - fuzz_init_detection_module(&ndpi_info_mod, 0); - } + /* To allow memory allocation failures */ + fuzz_set_alloc_callbacks_and_seed(size); ndpi_hll_init(&hll, fuzzed_data.ConsumeIntegral()); -- cgit v1.2.3