Skip to content

Commit fd9be78

Browse files
[3.13] gh-140979: Fix off-by-one error in the RE code validator (GH-140984) (GH-141000)
It was too lenient and allowed MARK opcodes with too large value. (cherry picked from commit 1326d2a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 551d68d commit fd9be78

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_sre/sre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
19321932
sre_match() code is robust even if they don't, and the worst
19331933
you can get is nonsensical match results. */
19341934
GET_ARG;
1935-
if (arg > 2 * (size_t)groups + 1) {
1935+
if (arg >= 2 * (size_t)groups) {
19361936
VTRACE(("arg=%d, groups=%d\n", (int)arg, (int)groups));
19371937
FAIL;
19381938
}

0 commit comments

Comments
 (0)