diff options
author | emanuele-f <faranda@ntop.org> | 2019-12-23 15:20:09 +0100 |
---|---|---|
committer | emanuele-f <faranda@ntop.org> | 2019-12-23 15:20:09 +0100 |
commit | 73c7ccdb65a1e13e3fb1726af7882dd34534906f (patch) | |
tree | 01378e4375555fdc1d8bdfb81f2a164f6f7466b0 /src | |
parent | 23421b47d998c6fc4f90070c34c0693362d95bed (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_main.c | 5 |
1 files changed, 3 insertions, 2 deletions
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) { |