aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_readerutils_workflow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fuzz/fuzz_readerutils_workflow.cpp')
-rw-r--r--fuzz/fuzz_readerutils_workflow.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/fuzz/fuzz_readerutils_workflow.cpp b/fuzz/fuzz_readerutils_workflow.cpp
index 90d0ac094..f753560f2 100644
--- a/fuzz/fuzz_readerutils_workflow.cpp
+++ b/fuzz/fuzz_readerutils_workflow.cpp
@@ -31,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ndpi_risk flow_risk;
const u_char *pkt;
struct pcap_pkthdr *header;
- int r;
+ int r, rc;
char errbuf[PCAP_ERRBUF_SIZE];
FILE *fd;
u_int8_t debug_protos_index;
@@ -91,14 +91,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
w = ndpi_workflow_init(&prefs, pcap_handle, 1, serialization_format);
if(w) {
NDPI_BITMASK_SET_ALL(enabled_bitmask);
- ndpi_set_protocol_detection_bitmask2(w->ndpi_struct, &enabled_bitmask);
- ndpi_finalize_initialization(w->ndpi_struct);
+ rc = ndpi_set_protocol_detection_bitmask2(w->ndpi_struct, &enabled_bitmask);
+ if(rc == 0) {
+ ndpi_finalize_initialization(w->ndpi_struct);
- header = NULL;
- r = pcap_next_ex(pcap_handle, &header, &pkt);
- while (r > 0) {
- ndpi_workflow_process_packet(w, header, pkt, &flow_risk);
+ header = NULL;
r = pcap_next_ex(pcap_handle, &header, &pkt);
+ while (r > 0) {
+ ndpi_workflow_process_packet(w, header, pkt, &flow_risk);
+ r = pcap_next_ex(pcap_handle, &header, &pkt);
+ }
}
ndpi_workflow_free(w);