bpo-38383: Fix possible integer overflow in startswith() of bytes and bytearray. (GH-16603)
(cherry picked from commit 24ddd9c2d6ab61cbce7e68d6de36d4df9bd2c3fb)
Co-authored-by: Hai Shi <shihai1992@gmail.com>
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index 37c5f7d..7d13184 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -743,7 +743,7 @@
if (direction < 0) {
/* startswith */
- if (start + slen > len)
+ if (start > len - slen)
goto notfound;
} else {
/* endswith */