diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2015-07-20 16:27:31 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2015-07-20 16:27:31 +0000 |
commit | 084a8fe109a94f6d146c6a7a0e397cc3d40c6b67 (patch) | |
tree | fa720c6aae61db21eb7438007b1c22f384c85590 | |
parent | 32c5e4cd1777e53d0da4e5e7bbd227725d12fc14 (diff) | |
download | pcre-084a8fe109a94f6d146c6a7a0e397cc3d40c6b67.tar.gz |
Fix bug for classes containing \\ sequences.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1578 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pcre_compile.c | 14 | ||||
-rw-r--r-- | testdata/testinput2 | 2 | ||||
-rw-r--r-- | testdata/testoutput2 | 2 |
4 files changed, 16 insertions, 6 deletions
@@ -84,6 +84,10 @@ Version 8.38 xx-xxx-xxxx 21. Fix infinite recursion in the JIT compiler when certain patterns such as /(?:|a|){100}x/ are analysed. +22. Some patterns with character classes involving [: and \\ were incorrectly + compiled and could cause reading from uninitialized memory or an incorrect + error diagnosis. + Version 8.37 28-April-2015 -------------------------- diff --git a/pcre_compile.c b/pcre_compile.c index ae76007..7912cc6 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -3905,11 +3905,11 @@ didn't consider this to be a POSIX class. Likewise for [:1234:]. The problem in trying to be exactly like Perl is in the handling of escapes. We have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code -below handles the special case of \], but does not try to do any other escape -processing. This makes it different from Perl for cases such as [:l\ower:] -where Perl recognizes it as the POSIX class "lower" but PCRE does not recognize -"l\ower". This is a lesser evil than not diagnosing bad classes when Perl does, -I think. +below handles the special cases \\ and \], but does not try to do any other +escape processing. This makes it different from Perl for cases such as +[:l\ower:] where Perl recognizes it as the POSIX class "lower" but PCRE does +not recognize "l\ower". This is a lesser evil than not diagnosing bad classes +when Perl does, I think. A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not. It seems that the appearance of a nested POSIX class supersedes an apparent @@ -3936,7 +3936,9 @@ 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 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET) + if (*ptr == CHAR_BACKSLASH && + (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET || + ptr[1] == CHAR_BACKSLASH)) ptr++; else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE; else diff --git a/testdata/testinput2 b/testdata/testinput2 index d206f44..ddb4b99 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4184,4 +4184,6 @@ backtracking verbs. --/ /(?(R))*+/BZ +/[[:\\](?'abc')[a:]/ + /-- End of testinput2 --/ diff --git a/testdata/testoutput2 b/testdata/testoutput2 index da81e10..ab0892b 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -14502,4 +14502,6 @@ Failed: unmatched parentheses at offset 23 End ------------------------------------------------------------------ +/[[:\\](?'abc')[a:]/ + /-- End of testinput2 --/ |