Fix a mismatch if \K was involved in a recursion

This commit is contained in:
Petr Písař 2021-02-19 16:05:17 +01:00
parent 0c6f2eb02b
commit 223b0aaf60
2 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,61 @@
From 1ef05f50d623582e8493ab49cfe0c243eed175c9 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu, 18 Feb 2021 09:46:08 +0000
Subject: [PATCH] Fix \K within recursion bug in interpreter.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1301 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.36.
---
src/pcre2_match.c | 4 +++-
testdata/testinput1 | 3 +++
testdata/testoutput1 | 4 ++++
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index e3f78c2..7d9cad0 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -818,10 +818,12 @@ fprintf(stderr, "++ op=%d\n", *Fecode);
/* N is now the frame of the recursion; the previous frame is at the
OP_RECURSE position. Go back there, copying the current subject position
- and mark, and move on past the OP_RECURSE. */
+ and mark, and the start_match position (\K might have changed it), and
+ then move on past the OP_RECURSE. */
P->eptr = Feptr;
P->mark = Fmark;
+ P->start_match = Fstart_match;
F = P;
Fecode += 1 + LINK_SIZE;
continue;
diff --git a/testdata/testinput1 b/testdata/testinput1
index bb4ddb7..4cf1126 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -6429,4 +6429,7 @@ ef) x/x,mark
/a{65536/
>a{65536<
+/a\K.(?0)*/
+ abac
+
# End of testinput1
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index 05b310b..8d4c108 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -10188,4 +10188,8 @@ No match
>a{65536<
0: a{65536
+/a\K.(?0)*/
+ abac
+ 0: c
+
# End of testinput1
--
2.26.2

View File

@ -9,7 +9,7 @@
#%%global rcversion RC1
Name: pcre2
Version: 10.36
Release: %{?rcversion:0.}3%{?rcversion:.%rcversion}%{?dist}
Release: %{?rcversion:0.}4%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
# the library: BSD with exceptions
@ -58,6 +58,8 @@ Patch1: pcre2-10.36-Get-rid-of-gcc-fanalyzer-error-though-it-was-probabl.pat
# a closing bracket as a quantifier, upstream bug #2690, in upstream after
# 10.36
Patch2: pcre2-10.36-Fix-some-numerical-checking-bugs-Bugzilla-2690.patch
# Fix a mismatch if \K was involved in a recursion, in upstream after 10.36
Patch3: pcre2-10.36-Fix-K-within-recursion-bug-in-interpreter.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: coreutils
@ -261,6 +263,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcre2test.*
%changelog
* Fri Feb 19 2021 Petr Pisar <ppisar@redhat.com> - 10.36-4
- Fix a mismatch if \K was involved in a recursion
* Tue Feb 02 2021 Petr Pisar <ppisar@redhat.com> - 10.36-3
- Fix misparsing long numbers as a backreference and a number without
a closing bracket as a quantifier (upstream bug #2690)