summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2015-07-22 09:33:04 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2015-07-22 09:33:04 +0000
commitabfc467cb9b2c51a7bcfa32c9b1926c21f2ed373 (patch)
tree4fdaf3139d84340a531dd0510b612b1983a0b4dc
parent7c9f98aa0d1ba2605294670d896ba36cf63edf04 (diff)
downloadpcre-abfc467cb9b2c51a7bcfa32c9b1926c21f2ed373.tar.gz
Fix (?R- not being diagnosed correctly.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1582 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog7
-rw-r--r--pcre_compile.c21
-rw-r--r--testdata/testinput22
-rw-r--r--testdata/testoutput23
4 files changed, 23 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index e68f416..93fd247 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -88,13 +88,16 @@ Version 8.38 xx-xxx-xxxx
compiled and could cause reading from uninitialized memory or an incorrect
error diagnosis.
-16. Pathological patterns containing many nested occurrences of [: caused
+23. Pathological patterns containing many nested occurrences of [: caused
pcre_compile() to run for a very long time.
-17. A conditional group with only one branch has an implicit empty alternative
+24. A conditional group with only one branch has an implicit empty alternative
branch and must therefore be treated as potentially matching an empty
string.
+25. If (?R was followed by - or + incorrect behaviour happened instead of a
+ diagnostic.
+
Version 8.37 28-April-2015
--------------------------
diff --git a/pcre_compile.c b/pcre_compile.c
index e9d1052..7d9f276 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -3936,7 +3936,7 @@ pcre_uchar terminator; /* Don't combine these lines; the Solaris cc */
terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
for (++ptr; *ptr != CHAR_NULL; ptr++)
{
- if (*ptr == CHAR_BACKSLASH &&
+ if (*ptr == CHAR_BACKSLASH &&
(ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
ptr[1] == CHAR_BACKSLASH))
ptr++;
@@ -6274,13 +6274,13 @@ for (;; ptr++)
}
while (*scode == OP_ALT);
}
-
- /* A conditional group with only one branch has an implicit empty
+
+ /* A conditional group with only one branch has an implicit empty
alternative branch. */
if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
- *bracode = OP_SCOND;
-
+ *bracode = OP_SCOND;
+
/* Handle possessive quantifiers. */
if (possessive_quantifier)
@@ -7337,9 +7337,14 @@ for (;; ptr++)
/* ------------------------------------------------------------ */
- case CHAR_R: /* Recursion */
- ptr++; /* Same as (?0) */
- /* Fall through */
+ case CHAR_R: /* Recursion, same as (?0) */
+ recno = 0;
+ if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
+ {
+ *errorcodeptr = ERR29;
+ goto FAILED;
+ }
+ goto HANDLE_RECURSION;
/* ------------------------------------------------------------ */
diff --git a/testdata/testinput2 b/testdata/testinput2
index d83c436..8f18fa4 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4190,4 +4190,6 @@ backtracking verbs. --/
/()(?(R)0)*+/BZ
+/(?R-:(?</
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 745832f..0ec4b36 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14523,4 +14523,7 @@ Failed: missing terminating ] for character class at offset 353
End
------------------------------------------------------------------
+/(?R-:(?</
+Failed: (?R or (?[+-]digits must be followed by ) at offset 3
+
/-- End of testinput2 --/