Fix mangled stack by invalid sscanf

This commit is contained in:
emanuele-f
2019-08-29 22:40:29 +02:00
parent fce2cd9817
commit 1bf23dc2a8
+6 -1
View File
@@ -2655,8 +2655,13 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_mod,
}
if(is_tcp || is_udp) {
if(sscanf(value, "%u-%u", (u_int32_t *)&range.port_low, (u_int32_t *)&range.port_high) != 2)
u_int p_low, p_high;
if(sscanf(value, "%u-%u", &p_low, &p_high) == 2)
range.port_low = p_low, range.port_high = p_high;
else
range.port_low = range.port_high = atoi(&elem[4]);
if(do_add)
addDefaultPort(ndpi_mod, &range, def, 1 /* Custom user proto */,
is_tcp ? &ndpi_mod->tcpRoot : &ndpi_mod->udpRoot, __FUNCTION__,__LINE__);