|
|
cb67f2 |
From a9d4fbce8772d129902eeb3d9a643e3f5943d818 Mon Sep 17 00:00:00 2001
|
|
|
cb67f2 |
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
|
|
|
cb67f2 |
Date: Sat, 12 Jul 2014 18:22:54 +0000
|
|
|
cb67f2 |
Subject: [PATCH] Fix compiler crash/misbehaviour for zero-repeated groups that
|
|
|
cb67f2 |
include a recursive back reference.
|
|
|
cb67f2 |
MIME-Version: 1.0
|
|
|
cb67f2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
cb67f2 |
Content-Transfer-Encoding: 8bit
|
|
|
cb67f2 |
|
|
|
cb67f2 |
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1495 2f5784b3-3f2a-0410-8824-cb99058d5e15
|
|
|
cb67f2 |
|
|
|
cb67f2 |
Petr Pisar: Ported to 8.32.
|
|
|
cb67f2 |
Note: The testoutput2 expect 'a?+', while it returns 'a?'. I raised
|
|
|
cb67f2 |
the anomaly to the upstream
|
|
|
cb67f2 |
<http://bugs.exim.org/show_bug.cgi?id=1503#c4>.
|
|
|
cb67f2 |
|
|
|
cb67f2 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
cb67f2 |
---
|
|
|
cb67f2 |
pcre_compile.c | 6 +++++-
|
|
|
cb67f2 |
testdata/testinput11 | 2 ++
|
|
|
cb67f2 |
testdata/testinput2 | 2 ++
|
|
|
cb67f2 |
testdata/testoutput11-16 | 24 ++++++++++++++++++++++++
|
|
|
cb67f2 |
testdata/testoutput11-32 | 24 ++++++++++++++++++++++++
|
|
|
cb67f2 |
testdata/testoutput11-8 | 24 ++++++++++++++++++++++++
|
|
|
cb67f2 |
testdata/testoutput2 | 24 ++++++++++++++++++++++++
|
|
|
cb67f2 |
7 files changed, 105 insertions(+), 1 deletion(-)
|
|
|
cb67f2 |
|
|
|
cb67f2 |
diff --git a/pcre_compile.c b/pcre_compile.c
|
|
|
cb67f2 |
index 8926099..0de3747 100644
|
|
|
cb67f2 |
--- a/pcre_compile.c
|
|
|
cb67f2 |
+++ b/pcre_compile.c
|
|
|
cb67f2 |
@@ -7316,12 +7316,16 @@ for (;;)
|
|
|
cb67f2 |
|
|
|
cb67f2 |
/* If it was a capturing subpattern, check to see if it contained any
|
|
|
cb67f2 |
recursive back references. If so, we must wrap it in atomic brackets.
|
|
|
cb67f2 |
- In any event, remove the block from the chain. */
|
|
|
cb67f2 |
+ Because we are moving code along, we must ensure that any pending recursive
|
|
|
cb67f2 |
+ references are updated. In any event, remove the block from the chain. */
|
|
|
cb67f2 |
|
|
|
cb67f2 |
if (capnumber > 0)
|
|
|
cb67f2 |
{
|
|
|
cb67f2 |
if (cd->open_caps->flag)
|
|
|
cb67f2 |
{
|
|
|
cb67f2 |
+ *code = OP_END;
|
|
|
cb67f2 |
+ adjust_recurse(start_bracket, 1 + LINK_SIZE,
|
|
|
cb67f2 |
+ (options & PCRE_UTF8) != 0, cd, cd->hwm);
|
|
|
cb67f2 |
memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
|
|
|
cb67f2 |
IN_UCHARS(code - start_bracket));
|
|
|
cb67f2 |
*start_bracket = OP_ONCE;
|
|
|
cb67f2 |
diff --git a/testdata/testinput11 b/testdata/testinput11
|
|
|
cb67f2 |
index 391ada7..7e8e542 100644
|
|
|
cb67f2 |
--- a/testdata/testinput11
|
|
|
cb67f2 |
+++ b/testdata/testinput11
|
|
|
cb67f2 |
@@ -132,4 +132,6 @@ is required for these tests. --/
|
|
|
cb67f2 |
|
|
|
cb67f2 |
/abc(d|e)(*THEN)x(123(*THEN)4|567(b|q)(*THEN)xx)/B
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/B
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput11 --/
|
|
|
cb67f2 |
diff --git a/testdata/testinput2 b/testdata/testinput2
|
|
|
cb67f2 |
index 0835a98..e6d0e87 100644
|
|
|
cb67f2 |
--- a/testdata/testinput2
|
|
|
cb67f2 |
+++ b/testdata/testinput2
|
|
|
cb67f2 |
@@ -3816,4 +3816,6 @@ settings of the anchored and startline bits. --/
|
|
|
cb67f2 |
"(?(?=)?==)(((((((((?=)))))))))"
|
|
|
cb67f2 |
a
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/BZ
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput2 --/
|
|
|
cb67f2 |
diff --git a/testdata/testoutput11-16 b/testdata/testoutput11-16
|
|
|
cb67f2 |
index dff72b9..de64e37 100644
|
|
|
cb67f2 |
--- a/testdata/testoutput11-16
|
|
|
cb67f2 |
+++ b/testdata/testoutput11-16
|
|
|
cb67f2 |
@@ -710,4 +710,28 @@ Memory allocation (code space): 14
|
|
|
cb67f2 |
62 End
|
|
|
cb67f2 |
------------------------------------------------------------------
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/B
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+ 0 39 Bra
|
|
|
cb67f2 |
+ 2 Brazero
|
|
|
cb67f2 |
+ 3 32 SCBra 1
|
|
|
cb67f2 |
+ 6 27 Once
|
|
|
cb67f2 |
+ 8 12 CBra 2
|
|
|
cb67f2 |
+ 11 7 CBra 3
|
|
|
cb67f2 |
+ 14 a
|
|
|
cb67f2 |
+ 16 \2
|
|
|
cb67f2 |
+ 18 7 Ket
|
|
|
cb67f2 |
+ 20 11 Alt
|
|
|
cb67f2 |
+ 22 5 CBra 4
|
|
|
cb67f2 |
+ 25 a*
|
|
|
cb67f2 |
+ 27 5 Ket
|
|
|
cb67f2 |
+ 29 22 Recurse
|
|
|
cb67f2 |
+ 31 23 Ket
|
|
|
cb67f2 |
+ 33 27 Ket
|
|
|
cb67f2 |
+ 35 32 KetRmax
|
|
|
cb67f2 |
+ 37 a?
|
|
|
cb67f2 |
+ 39 39 Ket
|
|
|
cb67f2 |
+ 41 End
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput11 --/
|
|
|
cb67f2 |
diff --git a/testdata/testoutput11-32 b/testdata/testoutput11-32
|
|
|
cb67f2 |
index 8335fb8..0d32e2f 100644
|
|
|
cb67f2 |
--- a/testdata/testoutput11-32
|
|
|
cb67f2 |
+++ b/testdata/testoutput11-32
|
|
|
cb67f2 |
@@ -710,4 +710,28 @@ Memory allocation (code space): 28
|
|
|
cb67f2 |
62 End
|
|
|
cb67f2 |
------------------------------------------------------------------
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/B
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+ 0 39 Bra
|
|
|
cb67f2 |
+ 2 Brazero
|
|
|
cb67f2 |
+ 3 32 SCBra 1
|
|
|
cb67f2 |
+ 6 27 Once
|
|
|
cb67f2 |
+ 8 12 CBra 2
|
|
|
cb67f2 |
+ 11 7 CBra 3
|
|
|
cb67f2 |
+ 14 a
|
|
|
cb67f2 |
+ 16 \2
|
|
|
cb67f2 |
+ 18 7 Ket
|
|
|
cb67f2 |
+ 20 11 Alt
|
|
|
cb67f2 |
+ 22 5 CBra 4
|
|
|
cb67f2 |
+ 25 a*
|
|
|
cb67f2 |
+ 27 5 Ket
|
|
|
cb67f2 |
+ 29 22 Recurse
|
|
|
cb67f2 |
+ 31 23 Ket
|
|
|
cb67f2 |
+ 33 27 Ket
|
|
|
cb67f2 |
+ 35 32 KetRmax
|
|
|
cb67f2 |
+ 37 a?
|
|
|
cb67f2 |
+ 39 39 Ket
|
|
|
cb67f2 |
+ 41 End
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput11 --/
|
|
|
cb67f2 |
diff --git a/testdata/testoutput11-8 b/testdata/testoutput11-8
|
|
|
cb67f2 |
index c1c85f9..9447fb6 100644
|
|
|
cb67f2 |
--- a/testdata/testoutput11-8
|
|
|
cb67f2 |
+++ b/testdata/testoutput11-8
|
|
|
cb67f2 |
@@ -710,4 +710,28 @@ Memory allocation (code space): 10
|
|
|
cb67f2 |
76 End
|
|
|
cb67f2 |
------------------------------------------------------------------
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/B
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+ 0 57 Bra
|
|
|
cb67f2 |
+ 3 Brazero
|
|
|
cb67f2 |
+ 4 48 SCBra 1
|
|
|
cb67f2 |
+ 9 40 Once
|
|
|
cb67f2 |
+ 12 18 CBra 2
|
|
|
cb67f2 |
+ 17 10 CBra 3
|
|
|
cb67f2 |
+ 22 a
|
|
|
cb67f2 |
+ 24 \2
|
|
|
cb67f2 |
+ 27 10 Ket
|
|
|
cb67f2 |
+ 30 16 Alt
|
|
|
cb67f2 |
+ 33 7 CBra 4
|
|
|
cb67f2 |
+ 38 a*
|
|
|
cb67f2 |
+ 40 7 Ket
|
|
|
cb67f2 |
+ 43 33 Recurse
|
|
|
cb67f2 |
+ 46 34 Ket
|
|
|
cb67f2 |
+ 49 40 Ket
|
|
|
cb67f2 |
+ 52 48 KetRmax
|
|
|
cb67f2 |
+ 55 a?
|
|
|
cb67f2 |
+ 57 57 Ket
|
|
|
cb67f2 |
+ 60 End
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput11 --/
|
|
|
cb67f2 |
diff --git a/testdata/testoutput2 b/testdata/testoutput2
|
|
|
cb67f2 |
index 66c914f..2a2b577 100644
|
|
|
cb67f2 |
--- a/testdata/testoutput2
|
|
|
cb67f2 |
+++ b/testdata/testoutput2
|
|
|
cb67f2 |
@@ -12491,4 +12491,28 @@ No set of starting bytes
|
|
|
cb67f2 |
a
|
|
|
cb67f2 |
No match
|
|
|
cb67f2 |
|
|
|
cb67f2 |
+/(((a\2)|(a*)\g<-1>))*a?/BZ
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+ Bra
|
|
|
cb67f2 |
+ Brazero
|
|
|
cb67f2 |
+ SCBra 1
|
|
|
cb67f2 |
+ Once
|
|
|
cb67f2 |
+ CBra 2
|
|
|
cb67f2 |
+ CBra 3
|
|
|
cb67f2 |
+ a
|
|
|
cb67f2 |
+ \2
|
|
|
cb67f2 |
+ Ket
|
|
|
cb67f2 |
+ Alt
|
|
|
cb67f2 |
+ CBra 4
|
|
|
cb67f2 |
+ a*
|
|
|
cb67f2 |
+ Ket
|
|
|
cb67f2 |
+ Recurse
|
|
|
cb67f2 |
+ Ket
|
|
|
cb67f2 |
+ Ket
|
|
|
cb67f2 |
+ KetRmax
|
|
|
cb67f2 |
+ a?
|
|
|
cb67f2 |
+ Ket
|
|
|
cb67f2 |
+ End
|
|
|
cb67f2 |
+------------------------------------------------------------------
|
|
|
cb67f2 |
+
|
|
|
cb67f2 |
/-- End of testinput2 --/
|
|
|
cb67f2 |
--
|
|
|
cb67f2 |
2.1.0
|
|
|
cb67f2 |
|