Fixed heap-buffer-overflow issue

This commit is contained in:
Luca Deri
2023-08-31 18:35:49 +02:00
parent 16b0ce3710
commit 19381f330a
+9 -1
View File
@@ -3402,7 +3402,15 @@ int ndpi_match_custom_category(struct ndpi_detection_module_struct *ndpi_str,
if(rc < 0) return rc; if(rc < 0) return rc;
return(id != NDPI_PROTOCOL_UNKNOWN ? 0 : -1); return(id != NDPI_PROTOCOL_UNKNOWN ? 0 : -1);
#else #else
u_int16_t rc = ndpi_domain_classify_contains(ndpi_str->custom_categories.sc_hostnames, name); char buf[128];
u_int16_t rc;
u_int max_len = sizeof(buf)-1;
if(name_len > max_len) name_len = max_len;
strncpy(buf, name, name_len);
buf[name_len] = '\0';
rc = ndpi_domain_classify_contains(ndpi_str->custom_categories.sc_hostnames, buf);
if(rc == 0) if(rc == 0)
return(-1); /* Not found */ return(-1); /* Not found */