Skip to content

Commit ce3c913

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 <[email protected]>
1 parent dc19124 commit ce3c913

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
@@ -743,7 +743,7 @@ tailmatch(const char *str, Py_ssize_t len, PyObject *substr,
743743

744744
if (direction < 0) {
745745
/* startswith */
746-
if (start + slen > len)
746+
if (start > len - slen)
747747
goto notfound;
748748
} else {
749749
/* endswith */

0 commit comments

Comments
 (0)