From 476cd1d96560aaf7f210319597556e7fbcd60469 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 18 Apr 2014 17:38:35 -0400 Subject: 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. --- src/string/memmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/string/memmem.c') diff --git a/src/string/memmem.c b/src/string/memmem.c index a5a249f2..3b1ae183 100644 --- a/src/string/memmem.c +++ b/src/string/memmem.c @@ -120,7 +120,7 @@ static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const } /* 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; } -- cgit v1.2.1