mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574) (#136628)
gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574)
(cherry picked from commit 85ec3b3b50)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
This commit is contained in:
parent
ed1e0cdc58
commit
348e22cf06
3 changed files with 14 additions and 4 deletions
|
|
@ -595,7 +595,7 @@ STRINGLIB(default_find)(const STRINGLIB_CHAR* s, Py_ssize_t n,
|
|||
continue;
|
||||
}
|
||||
/* miss: check if next character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
if (i + 1 <= w && !STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
i = i + m;
|
||||
}
|
||||
else {
|
||||
|
|
@ -604,7 +604,7 @@ STRINGLIB(default_find)(const STRINGLIB_CHAR* s, Py_ssize_t n,
|
|||
}
|
||||
else {
|
||||
/* skip: check if next character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
if (i + 1 <= w && !STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
i = i + m;
|
||||
}
|
||||
}
|
||||
|
|
@ -668,7 +668,7 @@ STRINGLIB(adaptive_find)(const STRINGLIB_CHAR* s, Py_ssize_t n,
|
|||
}
|
||||
}
|
||||
/* miss: check if next character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
if (i + 1 <= w && !STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
i = i + m;
|
||||
}
|
||||
else {
|
||||
|
|
@ -677,7 +677,7 @@ STRINGLIB(adaptive_find)(const STRINGLIB_CHAR* s, Py_ssize_t n,
|
|||
}
|
||||
else {
|
||||
/* skip: check if next character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
if (i + 1 <= w && !STRINGLIB_BLOOM(mask, ss[i+1])) {
|
||||
i = i + m;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue