From 03ecb026ff4d0e545cf21d463807b40265441bb3 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:19:03 +0100 Subject: fuzz: improve fuzzing coverage (#2309) --- fuzz/fuzz_ds_tree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fuzz/fuzz_ds_tree.cpp') diff --git a/fuzz/fuzz_ds_tree.cpp b/fuzz/fuzz_ds_tree.cpp index d06b5b19f..5e561e2e6 100644 --- a/fuzz/fuzz_ds_tree.cpp +++ b/fuzz/fuzz_ds_tree.cpp @@ -46,7 +46,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { *entry = fuzzed_data.ConsumeIntegral(); if(ndpi_tfind(entry, &root, __compare) == NULL) { - if(ndpi_tsearch(entry, &root, __compare) == NULL) { + if(ndpi_tsearch(entry, fuzzed_data.ConsumeBool() ? &root : NULL, __compare) == NULL) { ndpi_free(entry); } else { /* Keep one random entry really added */ @@ -65,7 +65,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { for (i = 0; i < num_iteration; i++) { e = fuzzed_data.ConsumeIntegral(); - ndpi_tfind(&e, &root, __compare); + ndpi_tfind(&e, fuzzed_data.ConsumeBool() ? &root : NULL, __compare); } /* Search of an added node */ if (is_added) { -- cgit v1.2.3