]> granicus.if.org Git - python/commitdiff
bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray....
authorHai Shi <shihai1992@gmail.com>
Sun, 6 Oct 2019 12:17:18 +0000 (20:17 +0800)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 6 Oct 2019 12:17:18 +0000 (15:17 +0300)
Objects/bytes_methods.c

index 37c5f7dbc8040bec2f5bc0e1905254932541a593..7d131842059228598cd5cb952cec002978c7acb1 100644 (file)
@@ -743,7 +743,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 */