aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_ds_patricia.cpp
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-01-20 14:27:33 +0100
committerGitHub <noreply@github.com>2023-01-20 14:27:33 +0100
commit5e8c1ebbb7f67033916ed4878cd6c2a662073898 (patch)
treef538977aa08015bffcf99ec9f6bb505c9143232c /fuzz/fuzz_ds_patricia.cpp
parent496b284c9888c090696cc8e570d0b20c08dc3d63 (diff)
fuzz: fix memory allocation failure logic (#1867)
We *do* want to have some allocation errors. Fix some related bugs Fix: 29be01ef
Diffstat (limited to 'fuzz/fuzz_ds_patricia.cpp')
-rw-r--r--fuzz/fuzz_ds_patricia.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/fuzz/fuzz_ds_patricia.cpp b/fuzz/fuzz_ds_patricia.cpp
index ba72dce5c..c514f3b00 100644
--- a/fuzz/fuzz_ds_patricia.cpp
+++ b/fuzz/fuzz_ds_patricia.cpp
@@ -6,8 +6,6 @@
#include <assert.h>
#include "fuzzer/FuzzedDataProvider.h"
-struct ndpi_detection_module_struct *ndpi_info_mod = NULL;
-
static void free_ptree_data(void *data) {
/* Nothing to do */
assert(data);
@@ -38,11 +36,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (fuzzed_data.remaining_bytes() < 1024)
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);
is_ipv6 = fuzzed_data.ConsumeBool();
if (is_ipv6)