aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2018-09-24 09:57:51 +0200
committerLuca Deri <deri@ntop.org>2018-09-24 09:57:51 +0200
commitf639c237a19cb79c39af1fc552e336d504af0bad (patch)
tree8c05a516eb2fadd6471c02424ab3b42d4d13e3b3 /src/lib
parent7117f0532c6229a2057d5f7cf1f0aa23abeb0ec8 (diff)
Added check for not going beyond the string lenght
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ndpi_main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 84a1de400..2c546d47d 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -5703,7 +5703,7 @@ char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
size_t len;
if((c = *find++) != '\0') {
- len = strlen(find);
+ len = strnlen(find, slen);
do {
do {
if(slen-- < 1 || (sc = *s++) == '\0')
@@ -5711,10 +5711,11 @@ char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
} while (sc != c);
if(len > slen)
return (NULL);
- } while (strncmp(s, find, len) != 0);
+ } while(strncmp(s, find, len) != 0);
s--;
}
- return ((char *)s);
+
+ return((char *)s);
}
/* ****************************************************** */