summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-08 08:57:04 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-08 08:57:04 +0000
commit5783ade86fa125a2c886ad890c49d601797c90b6 (patch)
tree2e0e58d320a0c3b5ed037ccbcd23b91fc00585b4
parent49c56a265833ec84377194fb95cf09b6592edf18 (diff)
downloadpcre-5783ade86fa125a2c886ad890c49d601797c90b6.tar.gz
Previous patch for fixing problem with recursion loop checking was incorrect.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@504 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--pcre_compile.c8
-rw-r--r--testdata/testinput22
-rw-r--r--testdata/testoutput23
3 files changed, 12 insertions, 1 deletions
diff --git a/pcre_compile.c b/pcre_compile.c
index 77b7c09..1a62ccb 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -1828,14 +1828,20 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
if (c == OP_RECURSE)
{
+ BOOL empty_branch = FALSE;
const uschar *scode = cd->start_code + GET(code, 1);
if (GET(scode, 1) == 0) return TRUE; /* Unclosed */
do
{
- if (!could_be_empty_branch(scode, endcode, utf8, cd)) return FALSE;
+ if (could_be_empty_branch(scode, endcode, utf8, cd))
+ {
+ empty_branch = TRUE;
+ break;
+ }
scode += GET(scode, 1);
}
while (*scode == OP_ALT);
+ if (!empty_branch) return FALSE; /* All branches are non-empty */
continue;
}
diff --git a/testdata/testinput2 b/testdata/testinput2
index dc20e82..94a18c9 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -3230,4 +3230,6 @@ a random value. /Ix
/----------------------/
+/(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
+
/-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 1b3c2f9..c29bd5f 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -10665,4 +10665,7 @@ No match
/----------------------/
+/(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
+Failed: recursive call could loop indefinitely at offset 31
+
/-- End of testinput2 --/