]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 8 Aug 2010 22:07:16 +0000 (22:07 +0000)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 8 Aug 2010 22:07:16 +0000 (22:07 +0000)
Misc/NEWS
Objects/stringlib/fastsearch.h

index 9f3d80a63d42b12472168114172b0b6d7f38f160..7aba37d83eab0f45507fbbc40cae076dec336755 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 2?
 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
   shutdown.
 
index 7525951c065084e5d0f626af4e92daa3da06fdf2..e231c587e4764fe281861759d76de7a8da9ec891 100644 (file)
@@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n,
                     /* got a match! */
                     return i;
                 /* 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;
                 else
                     i = i - skip;
             } else {
                 /* 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;
             }
         }