From 73c7ccdb65a1e13e3fb1726af7882dd34534906f Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Mon, 23 Dec 2019 15:20:09 +0100 Subject: Fix crash in ndpi_fill_ip_protocol_category when both saddr and daddr are 0 In this corner case, the "prefix" variable was not initialized leading to a failed assertion and crash: ndpi_patricia_search_best2: Assertion `prefix->bitlen <= patricia->maxbits' failed. --- src/lib/ndpi_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 14524ff7c..fdf01fde2 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -4578,10 +4578,11 @@ int ndpi_fill_ip_protocol_category(struct ndpi_detection_module_struct *ndpi_str } if(!node) { - if(daddr != 0) + if(daddr != 0) { fill_prefix_v4(&prefix, (struct in_addr *)&daddr, 32, ((patricia_tree_t*)ndpi_str->protocols_ptree)->maxbits); - node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix); + node = ndpi_patricia_search_best(ndpi_str->custom_categories.ipAddresses, &prefix); + } } if(node) { -- cgit v1.2.3