From e2370d6861990e9aba7b551e51cfa04d945f4510 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 16 Dec 2021 10:23:40 +0100 Subject: [PATCH] fuzz: cleans all flow after one run Makes the fuzz target more stateless And manages to find bugs on the FlowFree path --- src/tests/fuzz/fuzz_predefpcap_aware.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tests/fuzz/fuzz_predefpcap_aware.c b/src/tests/fuzz/fuzz_predefpcap_aware.c index 74e387f00a..4dfc27c444 100644 --- a/src/tests/fuzz/fuzz_predefpcap_aware.c +++ b/src/tests/fuzz/fuzz_predefpcap_aware.c @@ -22,6 +22,7 @@ #include "util-unittest-helper.h" #include "conf-yaml-loader.h" #include "pkt-var.h" +#include "flow-util.h" #include @@ -142,6 +143,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) p->pcap_cnt = pcap_cnt; } PacketFree(p); + for (uint32_t u = 0; u < flow_config.hash_size; u++) { + Flow *f = flow_hash[u].head; + while (f) { + Flow *n = f->next; + uint8_t proto_map = FlowGetProtoMapping(f->proto); + FlowClearMemory(f, proto_map); + FlowFree(f); + f = n; + } + flow_hash[u].head = NULL; + } return 0; }