diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2024-05-11 23:37:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-11 23:37:31 +0200 |
commit | a064261e854317bcc48aab31f86f3cbee67855c3 (patch) | |
tree | e913f6308457f41f1398434017bec6f71ffc1339 /example/ndpiReader.c | |
parent | 2d33431948ce6fb75ee7117544b887f34c495444 (diff) |
Revert `ndpi_strnstr()` optimization introduced in a813121e0 (#2439)
New implementation fails tests 11b, 12 and 13.
Revert to the original (BSD) implementation (with also some basic
parameters check)
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 7a326f71b..cf26d0841 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -5691,6 +5691,16 @@ void strnstrUnitTest(void) { /* Test 10: substring equal to the string */ assert(strcmp(ndpi_strnstr("string", "string", 6), "string") == 0); + + /* Test 11a,b: max_length bigger that string length */ + assert(strcmp(ndpi_strnstr("string", "string", 66), "string") == 0); + assert(ndpi_strnstr("string", "a", 66) == NULL); + + /* Test 12: substring longer than the string */ + assert(ndpi_strnstr("string", "stringA", 6) == NULL); + + /* Test 13 */ + assert(ndpi_strnstr("abcdef", "abc", 2) == NULL); } /* *********************************************** */ |