Fix bug in VERSION number reading.

This commit is contained in:
Philip.Hazel 2018-07-02 12:26:04 +00:00
parent b2294373d7
commit 50aa69657e
4 changed files with 13 additions and 4 deletions

View File

@ -105,6 +105,9 @@ complicated algorithm has now been implemented.
correctly ignored, but qualifiers on lookaheads were not being ignored, leading correctly ignored, but qualifiers on lookaheads were not being ignored, leading
to an incorrect "lookbehind assertion is not fixed length" error. to an incorrect "lookbehind assertion is not fixed length" error.
23. The VERSION condition test was reading fractional PCRE2 version numbers
such as the 04 in 10.04 incorrectly and hence giving wrong results.
Version 10.31 12-February-2018 Version 10.31 12-February-2018
------------------------------ ------------------------------

View File

@ -3896,9 +3896,8 @@ while (ptr < ptrend)
if (*ptr == CHAR_DOT) if (*ptr == CHAR_DOT)
{ {
if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION; if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
if (!read_number(&ptr, ptrend, -1, 99 , ERR79, &minor, &errorcode)) minor = (*ptr++ - CHAR_0) * 10;
goto FAILED; if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0;
if (minor < 10) minor *= 10;
if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS) if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
goto BAD_VERSION_CONDITION; goto BAD_VERSION_CONDITION;
} }

3
testdata/testinput2 vendored
View File

@ -4007,6 +4007,9 @@
/(?(VERSION>=10.0)yes|no)/I /(?(VERSION>=10.0)yes|no)/I
yesno yesno
/(?(VERSION>=10.04)yes|no)/
yesno
/(?(VERSION=8)yes){3}/BI,aftertext /(?(VERSION=8)yes){3}/BI,aftertext
yesno yesno

View File

@ -13483,6 +13483,10 @@ Subject length lower bound = 2
yesno yesno
0: yes 0: yes
/(?(VERSION>=10.04)yes|no)/
yesno
0: yes
/(?(VERSION=8)yes){3}/BI,aftertext /(?(VERSION=8)yes){3}/BI,aftertext
------------------------------------------------------------------ ------------------------------------------------------------------
Bra Bra
@ -13537,7 +13541,7 @@ Failed: error 179 at offset 11: syntax error or number too big in (?(VERSION con
Failed: error 179 at offset 16: syntax error or number too big in (?(VERSION condition Failed: error 179 at offset 16: syntax error or number too big in (?(VERSION condition
/(?(VERSION=10.101)yes|no)/ /(?(VERSION=10.101)yes|no)/
Failed: error 179 at offset 17: syntax error or number too big in (?(VERSION condition Failed: error 179 at offset 16: syntax error or number too big in (?(VERSION condition
/abcd/I /abcd/I
Capturing subpattern count = 0 Capturing subpattern count = 0