提交 476cd1d9 编写于 作者: R Rich Felker

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.
上级 fbeadd15
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -84,7 +84,7 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n)
}
/* Compare left half */
for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
if (k == mem) return (wchar_t *)h;
if (k <= mem) return (wchar_t *)h;
h += p;
mem = mem0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册