Fixes #853 and adds a self check for duplicates

This commit is contained in:
Luca Deri
2020-04-07 19:17:37 +02:00
parent dea883a25d
commit db8497778d
3 changed files with 21 additions and 4 deletions
+18
View File
@@ -691,6 +691,24 @@ static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_str) {
/* ******************************************************************** */
/* Self check function to be called onli for testing purposes */
void ndpi_self_check_host_match() {
u_int32_t i, j;
for(i=0; host_match[i].string_to_match != NULL; i++) {
for(j=0; host_match[j].string_to_match != NULL; j++) {
if((i != j) && (strcmp(host_match[i].string_to_match, host_match[j].string_to_match) == 0)) {
printf("[INTERNAL ERROR]: Duplicate string detected '%s' [id: %u, id %u]\n",
host_match[i].string_to_match, i, j);
printf("\nPlease fix host_match[] in ndpi_content_match.c.inc\n");
exit(0);
}
}
}
}
/* ******************************************************************** */
static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_str) {
int i;