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