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