summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-08-20 12:58:29 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-08-20 12:58:29 +0000
commit0a908e143daddbf745af3c2a13a0f5debf5f532a (patch)
treedbbcb82b7bfa16e6aebfe05b53e63bba1415b1ba
parent86d4fce0384fc9825e0e2cf81d9a4ebef117d7ca (diff)
downloadpcre-0a908e143daddbf745af3c2a13a0f5debf5f532a.tar.gz
Fix loop for group with possible zero repeat containing \p or \P.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@224 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog3
-rw-r--r--pcre_compile.c21
-rw-r--r--testdata/testinput618
-rw-r--r--testdata/testoutput618
4 files changed, 60 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 94b478f..b410350 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -147,6 +147,9 @@ Version 7.3 20-Aug-07
26. Patterns such as [\P{Yi}A] which include \p or \P and just one other
character were causing crashes (broken optimization).
+
+27. Patterns such as (\P{Yi}*\277)* (group with possible zero repeat containing
+ \p or \P) caused a compile-time loop.
Version 7.2 19-Jun-07
diff --git a/pcre_compile.c b/pcre_compile.c
index a1370d0..e344ad4 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -1596,6 +1596,26 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
case OP_TYPEPOSPLUS:
case OP_TYPEEXACT:
return FALSE;
+
+ /* These are going to continue, as they may be empty, but we have to
+ fudge the length for the \p and \P cases. */
+
+ case OP_TYPESTAR:
+ case OP_TYPEMINSTAR:
+ case OP_TYPEPOSSTAR:
+ case OP_TYPEQUERY:
+ case OP_TYPEMINQUERY:
+ case OP_TYPEPOSQUERY:
+ if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
+ break;
+
+ /* Same for these */
+
+ case OP_TYPEUPTO:
+ case OP_TYPEMINUPTO:
+ case OP_TYPEPOSUPTO:
+ if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
+ break;
/* End of branch */
@@ -1759,6 +1779,7 @@ adjust_recurse(uschar *group, int adjust, BOOL utf8, compile_data *cd,
uschar *save_hwm)
{
uschar *ptr = group;
+
while ((ptr = (uschar *)find_recurse(ptr, utf8)) != NULL)
{
int offset;
diff --git a/testdata/testinput6 b/testdata/testinput6
index 14b0645..53d2b32 100644
--- a/testdata/testinput6
+++ b/testdata/testinput6
@@ -814,4 +814,22 @@ was broken in all cases./
/[^\P{Yi}\P{Yi}\P{Yi}A]/
+/(\P{Yi}*\277)*/
+
+/(\P{Yi}*?\277)*/
+
+/(\p{Yi}*+\277)*/
+
+/(\P{Yi}?\277)*/
+
+/(\P{Yi}??\277)*/
+
+/(\p{Yi}?+\277)*/
+
+/(\P{Yi}{0,3}\277)*/
+
+/(\P{Yi}{0,3}?\277)*/
+
+/(\p{Yi}{0,3}+\277)*/
+
/ End of testinput6 /
diff --git a/testdata/testoutput6 b/testdata/testoutput6
index a39cf0e..0a58b84 100644
--- a/testdata/testoutput6
+++ b/testdata/testoutput6
@@ -1504,4 +1504,22 @@ No match
/[^\P{Yi}\P{Yi}\P{Yi}A]/
+/(\P{Yi}*\277)*/
+
+/(\P{Yi}*?\277)*/
+
+/(\p{Yi}*+\277)*/
+
+/(\P{Yi}?\277)*/
+
+/(\P{Yi}??\277)*/
+
+/(\p{Yi}?+\277)*/
+
+/(\P{Yi}{0,3}\277)*/
+
+/(\P{Yi}{0,3}?\277)*/
+
+/(\p{Yi}{0,3}+\277)*/
+
/ End of testinput6 /