Skip to content

Commit b40442b

Browse files
bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray. (GH-16603)
(cherry picked from commit 24ddd9c) Co-authored-by: Hai Shi <shihai1992@gmail.com>
1 parent 6c3fbbc commit b40442b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Objects/bytes_methods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ tailmatch(const char *str, Py_ssize_t len, PyObject *substr,
757757

758758
if (direction < 0) {
759759
/* startswith */
760-
if (start + slen > len)
760+
if (start > len - slen)
761761
goto notfound;
762762
} else {
763763
/* endswith */

0 commit comments

Comments
 (0)