summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib/fastsearch.h
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-07-13 13:58:03 (GMT)
committerGitHub <noreply@github.com>2025-07-13 13:58:03 (GMT)
commit348e22cf060695fbd57f099b94f0f9067bb49fca (patch)
tree5922d8aed5cc0fd74bb75ef1fa2673dc10ebfecf /Objects/stringlib/fastsearch.h
parented1e0cdc581d328177992e45c74d497c7da22ce2 (diff)
downloadcpython-348e22cf060695fbd57f099b94f0f9067bb49fca.zip
cpython-348e22cf060695fbd57f099b94f0f9067bb49fca.tar.gz
cpython-348e22cf060695fbd57f099b94f0f9067bb49fca.tar.bz2
[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 85ec3b3b503ffd5b7e45f8b3fa2cec0c10e4bef0) Co-authored-by: Duane Griffin <duaneg@dghda.com>
Diffstat (limited to 'Objects/stringlib/fastsearch.h')
-rw-r--r--Objects/stringlib/fastsearch.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
index 05e700b..b447865 100644
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -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;
}
}