diff options
author | Luca <deri@ntop.org> | 2023-08-21 23:19:57 +0200 |
---|---|---|
committer | Luca <deri@ntop.org> | 2023-08-21 23:19:57 +0200 |
commit | 9933b5910d4ffa1024478c28bd4b5952eaf9637d (patch) | |
tree | dc355f41cdd9fadefb7ffbcd56760b15277e52f9 | |
parent | bd25df33346555b20918239bb0ec3ce11b6219c8 (diff) |
Boundary check
-rw-r--r-- | src/lib/ndpi_main.c | 16 |
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]; |