From db8497778ddc578a58caf5447f0b5de3972f64c6 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Tue, 7 Apr 2020 19:17:37 +0200 Subject: Fixes #853 and adds a self check for duplicates --- src/lib/ndpi_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/ndpi_main.c') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 4a187c9a9..5c016174b 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -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; -- cgit v1.2.3