]> granicus.if.org Git - python/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:37:20 +0000 (05:37 -0700)
committerGitHub <noreply@github.com>
Sun, 6 Oct 2019 12:37:20 +0000 (05:37 -0700)
(cherry picked from commit 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
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 */