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.
This commit is contained in:
emanuele-f
2019-12-23 15:20:09 +01:00
parent 23421b47d9
commit 73c7ccdb65
+3 -2
View File
@@ -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) {