[Python-checkins] bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray. (GH-16603)

Serhiy Storchaka webhook-mailer at python.org
Sun Oct 6 08:17:23 EDT 2019


https://github.com/python/cpython/commit/24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb
commit: 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb
branch: master
author: Hai Shi <shihai1992 at gmail.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2019-10-06T15:17:18+03:00
summary:

bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray. (GH-16603)

files:
M Objects/bytes_methods.c

diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index 37c5f7dbc8040..7d13184205922 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -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 */



More information about the Python-checkins mailing list