From fbb9700086eff42ed315be3d41c97860006ae9ae Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Mon, 21 Feb 2022 20:32:50 +0100 Subject: fuzz: purge old sessions (#1451) At every fuzz iteration (i.e for every trace file): * keep the same ndpi context (`ndpi_init_detection_module` is very slow); * reset the flow table, otherwise it grows indefinitely. This change should fix the "out-of-memory" errors reported by oss-fuzz. --- example/reader_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'example/reader_util.c') diff --git a/example/reader_util.c b/example/reader_util.c index 3340170ef..b16a1838c 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -391,7 +391,7 @@ extern char *_debug_protocols; static int _debug_protocols_ok = 0; struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, - pcap_t * pcap_handle) { + pcap_t * pcap_handle, int do_init_flows_root) { struct ndpi_detection_module_struct * module; struct ndpi_workflow * workflow; @@ -427,7 +427,8 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref if(_debug_protocols_ok) ndpi_set_debug_bitmask(module, debug_bitmask); - workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *)); + if(do_init_flows_root) + workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *)); return workflow; } -- cgit v1.2.3