fix false negatives with periodic needles in strstr, wcsstr, and memmem

in cases where the memorized match range from the right factor
exceeded the length of the left factor, it was wrongly treated as a
mismatch rather than a match.

issue reported by Yves Bastide.
This commit is contained in:
Rich Felker committed 2014-04-18 17:38:35 -04:00
1 parent fbeadd150f
commit 476cd1d965
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
if (k == mem) return (char *)h;
if (k <= mem) return (char *)h;
h += p;
mem = mem0;
}