Skip to content

Commit 267af29

Browse files
[3.14] gh-140979: Fix off-by-one error in the RE code validator (GH-140984) (GH-141001)
It was too lenient and allowed MARK opcodes with too large value. (cherry picked from commit 1326d2a) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent c3f9702 commit 267af29

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
@@ -1942,7 +1942,7 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
19421942
sre_match() code is robust even if they don't, and the worst
19431943
you can get is nonsensical match results. */
19441944
GET_ARG;
1945-
if (arg > 2 * (size_t)groups + 1) {
1945+
if (arg >= 2 * (size_t)groups) {
19461946
VTRACE(("arg=%d, groups=%d\n", (int)arg, (int)groups));
19471947
FAIL;
19481948
}

0 commit comments

Comments
 (0)