Revision: 454
http://www.exim.org/viewvc/pcre2?view=rev&revision=454
Author: ph10
Date: 2015-12-01 17:41:24 +0000 (Tue, 01 Dec 2015)
Log Message:
-----------
Fix extended *verb name ignored terminating whitespace bug.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-11-30 17:31:16 UTC (rev 453)
+++ code/trunk/ChangeLog 2015-12-01 17:41:24 UTC (rev 454)
@@ -353,7 +353,12 @@
pcre2_compile() to misbehave when auto callouts were enabled. This bug
was found by the LLVM fuzzer.
+106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
+other verb "name" ended with whitespace immediately before the closing
+parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
+both those options were set.
+
Version 10.20 30-June-2015
--------------------------
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2015-11-30 17:31:16 UTC (rev 453)
+++ code/trunk/src/pcre2_compile.c 2015-12-01 17:41:24 UTC (rev 454)
@@ -3013,15 +3013,14 @@
{
if (x == CHAR_RIGHT_PARENTHESIS) break;
- /* Skip over comments and whitespace in extended mode. Need a loop to
- handle whitespace after a comment. */
+ /* Skip over comments and whitespace in extended mode. */
if ((options & PCRE2_EXTENDED) != 0)
{
- for (;;)
- {
- while (MAX_255(x) && (cb->ctypes[x] & ctype_space) != 0) x = *(++ptr);
- if (x != CHAR_NUMBER_SIGN) break;
+ PCRE2_SPTR wscptr = ptr;
+ while (MAX_255(x) && (cb->ctypes[x] & ctype_space) != 0) x = *(++ptr);
+ if (x == CHAR_NUMBER_SIGN)
+ {
ptr++;
while (*ptr != CHAR_NULL)
{
@@ -3035,9 +3034,15 @@
if (utf) FORWARDCHAR(ptr);
#endif
}
- x = *ptr; /* Either NULL or the char after a newline */
+ }
+
+ /* If we have skipped any characters, restart the loop. */
+
+ if (ptr > wscptr)
+ {
+ ptr--;
+ continue;
}
- if (ptr >= cb->end_pattern) break;
}
/* Process escapes */
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2015-11-30 17:31:16 UTC (rev 453)
+++ code/trunk/testdata/testinput2 2015-12-01 17:41:24 UTC (rev 454)
@@ -4702,4 +4702,6 @@
/()\Q\E*]/B,auto_callout
a[bc]d
+/\x8a+f|;T?(*:;.'?`(\xeap ){![^()!y*''C*(?';]{1;(\x08)/B,alt_verbnames,dupnames,extended
+
# End of testinput2
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2015-11-30 17:31:16 UTC (rev 453)
+++ code/trunk/testdata/testoutput2 2015-12-01 17:41:24 UTC (rev 454)
@@ -14979,4 +14979,23 @@
0: ]
1:
+/\x8a+f|;T?(*:;.'?`(\xeap ){![^()!y*''C*(?';]{1;(\x08)/B,alt_verbnames,dupnames,extended
+------------------------------------------------------------------
+ Bra
+ \x{8a}++
+ f
+ Alt
+ ;
+ T?
+ *MARK ;.'?`(\x{ea}p
+ {!
+ [\x00- "-&+-:<->@-BD-xz-\xff] (neg)
+ {1;
+ CBra 1
+ \x08
+ Ket
+ Ket
+ End
+------------------------------------------------------------------
+
# End of testinput2