Revision: 407
http://www.exim.org/viewvc/pcre2?view=rev&revision=407
Author: ph10
Date: 2015-11-01 17:31:48 +0000 (Sun, 01 Nov 2015)
Log Message:
-----------
Bad max lookbehind length was calculated when a back reference contained a
recursion.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput10
code/trunk/testdata/testoutput10
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-11-01 16:54:17 UTC (rev 406)
+++ code/trunk/ChangeLog 2015-11-01 17:31:48 UTC (rev 407)
@@ -252,7 +252,10 @@
lookbehind involved an out-of-bounds pointer, which could potentially cause
trouble in some environments.
+73. The maximum lookbehind length was incorrectly calculated for patterns such
+as /(?<=(a)(?-1))x/ which have a recursion within a backreference.
+
Version 10.20 30-June-2015
--------------------------
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2015-11-01 16:54:17 UTC (rev 406)
+++ code/trunk/src/pcre2_compile.c 2015-11-01 17:31:48 UTC (rev 407)
@@ -8378,7 +8378,7 @@
re->last_codeunit = 0;
re->bsr_convention = bsr;
re->newline_convention = newline;
-re->max_lookbehind =
+re->max_lookbehind = 0;
re->minlength = 0;
re->top_bracket = 0;
re->top_backref = 0;
@@ -8587,6 +8587,13 @@
}
cc += 1 + LINK_SIZE;
}
+
+ /* The previous value of the maximum lookbehind was transferred to the
+ compiled regex block above. We could have updated this value in the loop
+ above, but keep the two values in step, just in case some later code below
+ uses the cb value. */
+
+ re->max_lookbehind = cb.max_lookbehind;
}
/* Failed to compile, or error while post-processing. Earlier errors get here
Modified: code/trunk/testdata/testinput10
===================================================================
--- code/trunk/testdata/testinput10 2015-11-01 16:54:17 UTC (rev 406)
+++ code/trunk/testdata/testinput10 2015-11-01 17:31:48 UTC (rev 407)
@@ -440,4 +440,7 @@
/abc/utf,replace=\xC3
abc
+/(?<=(a)(?-1))x/I,utf
+ a\x80zx\=offset=3
+
# End of testinput10
Modified: code/trunk/testdata/testoutput10
===================================================================
--- code/trunk/testdata/testoutput10 2015-11-01 16:54:17 UTC (rev 406)
+++ code/trunk/testdata/testoutput10 2015-11-01 17:31:48 UTC (rev 407)
@@ -1527,4 +1527,13 @@
abc
Failed: error -3: UTF-8 error: 1 byte missing at end
+/(?<=(a)(?-1))x/I,utf
+Capturing subpattern count = 1
+Max lookbehind = 2
+Options: utf
+First code unit = 'x'
+Subject length lower bound = 1
+ a\x80zx\=offset=3
+Failed: error -22: UTF-8 error: isolated 0x80 byte at offset 1
+
# End of testinput10