From 267af2983246012f0c9bdc141dd9ef503a12d58b Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 4 Nov 2025 17:16:51 +0100 Subject: [PATCH] [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 1326d2a808245e5f2de9e515460bab30556e8f05) Co-authored-by: Serhiy Storchaka --- Modules/_sre/sre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index 694a66818f90..2761c76a3792 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -1942,7 +1942,7 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups) sre_match() code is robust even if they don't, and the worst you can get is nonsensical match results. */ GET_ARG; - if (arg > 2 * (size_t)groups + 1) { + if (arg >= 2 * (size_t)groups) { VTRACE(("arg=%d, groups=%d\n", (int)arg, (int)groups)); FAIL; } -- 2.47.3