Commit eb6f3ead authored by Florent Xicluna's avatar Florent Xicluna

Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.

parent bddc9fe2
...@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 2? ...@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 2?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #8530: Prevent stringlib fastsearch from reading beyond the front
of an array.
- Issue #5319: Print an error if flushing stdout fails at interpreter - Issue #5319: Print an error if flushing stdout fails at interpreter
shutdown. shutdown.
......
...@@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n, ...@@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n,
/* got a match! */ /* got a match! */
return i; return i;
/* miss: check if previous character is part of pattern */ /* miss: check if previous character is part of pattern */
if (!STRINGLIB_BLOOM(mask, s[i-1])) if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
i = i - m; i = i - m;
else else
i = i - skip; i = i - skip;
} else { } else {
/* skip: check if previous character is part of pattern */ /* skip: check if previous character is part of pattern */
if (!STRINGLIB_BLOOM(mask, s[i-1])) if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
i = i - m; i = i - m;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment