fuzz: fix memory allocation failure logic (#1867)

We *do* want to have some allocation errors.
Fix some related bugs
Fix: 29be01ef
This commit is contained in:
Ivan Nardi
2023-01-20 14:27:33 +01:00
committed by GitHub
parent 496b284c98
commit 5e8c1ebbb7
280 changed files with 161 additions and 124 deletions
+2 -8
View File
@@ -9,9 +9,6 @@
extern "C" int ac_domain_match_handler(AC_MATCH_t *m, AC_TEXT_t *txt, AC_REP_t *match);
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, is_added = 0;
@@ -30,11 +27,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);
if (fuzzed_data.ConsumeBool())
mc = ac_domain_match_handler;