aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca <deri@ntop.org>2023-08-21 23:19:57 +0200
committerLuca <deri@ntop.org>2023-08-21 23:19:57 +0200
commit9933b5910d4ffa1024478c28bd4b5952eaf9637d (patch)
treedc355f41cdd9fadefb7ffbcd56760b15277e52f9
parentbd25df33346555b20918239bb0ec3ce11b6219c8 (diff)
Boundary check
-rw-r--r--src/lib/ndpi_main.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 8c553ef7f..cc3782d55 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -4001,17 +4001,19 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str,
is_ip = 1, value = &attr[3];
else if(strncmp(attr, "host:", 5) == 0) {
/* host:"<value>",host:"<value>",.....@<subproto> */
- u_int i, max_len;
-
value = &attr[5];
if(value[0] == '"')
value++; /* remove leading " */
- max_len = strlen(value) - 1;
- if(value[max_len] == '"')
- value[max_len] = '\0'; /* remove trailing " */
-
- for(i=0; i<max_len; i++) value[i] = tolower(value[i]);
+ if(value[0] != '\0') {
+ u_int i, max_len = strlen(value) - 1;
+
+ if(value[max_len] == '"')
+ value[max_len] = '\0'; /* remove trailing " */
+
+ for(i=0; i<max_len; i++)
+ value[i] = tolower(value[i]);
+ }
} else if(strncmp(attr, "nbpf:", 5) == 0) {
#ifdef HAVE_NBPF
char *filter = &attr[5];