ppisar pushed to pcre (f20). "Fix pcretest loop when \K is used in a lookbehind assertion"
notifications at fedoraproject.org
notifications at fedoraproject.org
Fri Apr 10 13:47:24 UTC 2015
>From 456506d7d13e1f05f6597223ca4c7e667d7b1193 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
Date: Fri, 10 Apr 2015 07:49:16 +0200
Subject: Fix pcretest loop when \K is used in a lookbehind assertion
diff --git a/pcre-8.33-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch b/pcre-8.33-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
new file mode 100644
index 0000000..715024a
--- /dev/null
+++ b/pcre-8.33-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
@@ -0,0 +1,175 @@
+From 8911d2b7f8380b0ac278f52f209adb47a3207813 Mon Sep 17 00:00:00 2001
+From: ph10 <ph10 at 2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Tue, 7 Apr 2015 16:19:03 +0000
+Subject: [PATCH] Fix pcretest loop for \K in lookbehind assertion.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream commit ported to 8.33:
+
+commit c3579a7581cb8b3ca3c9617d63083afea29de646
+Author: ph10 <ph10 at 2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Tue Apr 7 16:19:03 2015 +0000
+
+ Fix pcretest loop for \K in lookbehind assertion.
+
+ git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1544 2f5784b3-3f2a-0410-8824-cb99058d5e15
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ pcretest.c | 30 +++++++++++++++++++++++++++---
+ testdata/testinput2 | 6 ++++++
+ testdata/testinput5 | 6 ++++++
+ testdata/testoutput2 | 28 ++++++++++++++++++++++++++++
+ testdata/testoutput5 | 28 ++++++++++++++++++++++++++++
+ 5 files changed, 95 insertions(+), 3 deletions(-)
+
+diff --git a/pcretest.c b/pcretest.c
+index 57ee041..2835aa0 100644
+--- a/pcretest.c
++++ b/pcretest.c
+@@ -5450,9 +5450,33 @@ while (!done)
+ g_notempty = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
+ }
+
+- /* For /g, update the start offset, leaving the rest alone */
+-
+- if (do_g) start_offset = use_offsets[1];
++ /* For /g, update the start offset, leaving the rest alone. There is a
++ tricky case when \K is used in a positive lookbehind assertion. This can
++ cause the end of the match to be less than or equal to the start offset.
++ In this case we restart at one past the start offset. This may return the
++ same match if the original start offset was bumped along during the
++ match, but eventually the new start offset will hit the actual start
++ offset. (In PCRE2 the true start offset is available, and this can be
++ done better. It is not worth doing more than making sure we do not loop
++ at this stage in the life of PCRE1.) */
++
++ if (do_g)
++ {
++ if (g_notempty == 0 && use_offsets[1] <= start_offset)
++ {
++ if (start_offset >= len) break; /* End of subject */
++ start_offset++;
++ if (use_utf)
++ {
++ while (start_offset < len)
++ {
++ if ((bptr[start_offset] & 0xc0) != 0x80) break;
++ start_offset++;
++ }
++ }
++ }
++ else start_offset = use_offsets[1];
++ }
+
+ /* For /G, update the pointer and length */
+
+diff --git a/testdata/testinput2 b/testdata/testinput2
+index b23fe6b..be22213 100644
+--- a/testdata/testinput2
++++ b/testdata/testinput2
+@@ -3847,4 +3847,10 @@ backtracking verbs. --/
+
+ "(?<=((?2))((?1)))"
+
++/(?<=\Ka)/g+
++ aaaaa
++
++/(?<=\Ka)/G+
++ aaaaa
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testinput5 b/testdata/testinput5
+index 642749c..602ce20 100644
+--- a/testdata/testinput5
++++ b/testdata/testinput5
+@@ -769,4 +769,10 @@
+
+ /\ud800/<JS>8
+
++/(?<=\K\x{17f})/8g+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++
++/(?<=\K\x{17f})/8G+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++
+ /-- End of testinput5 --/
+diff --git a/testdata/testoutput2 b/testdata/testoutput2
+index 028b100..4d5510c 100644
+--- a/testdata/testoutput2
++++ b/testdata/testoutput2
+@@ -12702,4 +12702,32 @@ No match
+ "(?<=((?2))((?1)))"
+ Failed: lookbehind assertion is not fixed length at offset 17
+
++/(?<=\Ka)/g+
++ aaaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaa
++ 0: a
++ 0+ aa
++ 0: a
++ 0+ a
++ 0: a
++ 0+
++
++/(?<=\Ka)/G+
++ aaaaa
++ 0: a
++ 0+ aaaa
++ 0: a
++ 0+ aaa
++ 0: a
++ 0+ aa
++ 0: a
++ 0+ a
++ 0: a
++ 0+
++
+ /-- End of testinput2 --/
+diff --git a/testdata/testoutput5 b/testdata/testoutput5
+index d583119..fcd646f 100644
+--- a/testdata/testoutput5
++++ b/testdata/testoutput5
+@@ -1846,4 +1846,32 @@ No match
+ /\ud800/<JS>8
+ Failed: disallowed Unicode code point (>= 0xd800 && <= 0xdfff) at offset 5
+
++/(?<=\K\x{17f})/8g+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}
++ 0: \x{17f}
++ 0+
++
++/(?<=\K\x{17f})/8G+
++ \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}\x{17f}
++ 0: \x{17f}
++ 0+ \x{17f}
++ 0: \x{17f}
++ 0+
++
+ /-- End of testinput5 --/
+--
+2.1.0
+
diff --git a/pcre.spec b/pcre.spec
index be628ca..75e7500 100644
--- a/pcre.spec
+++ b/pcre.spec
@@ -53,6 +53,9 @@ Patch13: pcre-8.33-Fix-stack-overflow-instead-of-diagnostic-for-mutual-.patch
# Fix pcregrep loop when \K is used in a lookbehind assertion, bug #1210423,
# in upstream after 8.36
Patch14: pcre-8.33-Fix-pcregrep-loop-when-K-is-used-in-a-lookbehind-ass.patch
+# Fix pcretest loop when \K is used in a lookbehind assertion, bug #1210423,
+# in upstream after 8.36
+Patch15: pcre-8.33-Fix-pcretest-loop-for-K-in-lookbehind-assertion.patch
BuildRequires: readline-devel
# New libtool to get rid of rpath
BuildRequires: autoconf, automake, libtool
@@ -107,6 +110,7 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
%patch12 -p1 -b .empty_string_check
%patch13 -p1 -b .mutual_recursion_in_assertion
%patch14 -p1 -b .pcregrep_k_loop
+%patch15 -p1 -b .pcretest_k_loop
# Because of rpath patch
libtoolize --copy --force && autoreconf -vif
# One contributor's name is non-UTF-8
@@ -177,6 +181,7 @@ make check
- Fix compliation of mutual recursion inside a lookbehind assertion
(bug #1210417)
- Fix pcregrep loop when \K is used in a lookbehind assertion (bug #1210423)
+- Fix pcretest loop when \K is used in a lookbehind assertion (bug #1210423)
* Tue Dec 02 2014 Petr Pisar <ppisar at redhat.com> - 8.33-8
- Fix CVE-2014-8964 (unused memory usage on zero-repeat assertion condition)
--
cgit v0.10.2
http://pkgs.fedoraproject.org/cgit/pcre.git/commit/?h=f20&id=456506d7d13e1f05f6597223ca4c7e667d7b1193
More information about the scm-commits
mailing list