Added check for not going beyond the string lenght

This commit is contained in:
Luca Deri
2018-09-24 09:57:51 +02:00
parent 7117f0532c
commit f639c237a1
+2 -1
View File
@@ -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')
@@ -5714,6 +5714,7 @@ char* ndpi_strnstr(const char *s, const char *find, size_t slen) {
} while(strncmp(s, find, len) != 0);
s--;
}
return((char *)s);
}