78f1eb
From 3295b48defa0f8570114877b063fe546dd348b3c Mon Sep 17 00:00:00 2001
78f1eb
From: Karl Williamson <khw@cpan.org>
78f1eb
Date: Thu, 20 Feb 2020 17:49:36 +0000
78f1eb
Subject: [PATCH 2/2] regcomp: use long jumps if there is any possibility of
78f1eb
 overflow
78f1eb
MIME-Version: 1.0
78f1eb
Content-Type: text/plain; charset=UTF-8
78f1eb
Content-Transfer-Encoding: 8bit
78f1eb
78f1eb
(CVE-2020-10878) Be conservative for backporting, we'll aim to do
78f1eb
something more aggressive for bleadperl.
78f1eb
78f1eb
(cherry picked from commit 9d7759db46f3b31b1d3f79c44266b6ba42a47fc6)
78f1eb
Signed-off-by: Petr Písař <ppisar@redhat.com>
78f1eb
---
78f1eb
 regcomp.c | 7 +++++++
78f1eb
 1 file changed, 7 insertions(+)
78f1eb
78f1eb
diff --git a/regcomp.c b/regcomp.c
78f1eb
index 4ba2980db6..73c35a6702 100644
78f1eb
--- a/regcomp.c
78f1eb
+++ b/regcomp.c
78f1eb
@@ -7762,6 +7762,13 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
78f1eb
 
78f1eb
         /* We have that number in RExC_npar */
78f1eb
         RExC_total_parens = RExC_npar;
78f1eb
+
78f1eb
+        /* XXX For backporting, use long jumps if there is any possibility of
78f1eb
+         * overflow */
78f1eb
+        if (RExC_size > U16_MAX && ! RExC_use_BRANCHJ) {
78f1eb
+            RExC_use_BRANCHJ = TRUE;
78f1eb
+            flags |= RESTART_PARSE;
78f1eb
+        }
78f1eb
     }
78f1eb
     else if (! MUST_RESTART(flags)) {
78f1eb
 	ReREFCNT_dec(Rx);
78f1eb
-- 
78f1eb
2.25.4
78f1eb