]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray....
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 6 Oct 2019 12:36:44 +0000 (05:36 -0700)
committerGitHub <noreply@github.com>
Sun, 6 Oct 2019 12:36:44 +0000 (05:36 -0700)
(cherry picked from commit 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
Objects/bytes_methods.c

index 07842f7469101365614139706d0bf2b3f35549e9..7c8ea815494e9251739024f973e7132aea788d7b 100644 (file)
@@ -757,7 +757,7 @@ tailmatch(const char *str, Py_ssize_t len, PyObject *substr,
 
     if (direction < 0) {
         /* startswith */
-        if (start + slen > len)
+        if (start > len - slen)
             goto notfound;
     } else {
         /* endswith */