Skip to content

Commit 5d42900

Browse files
committed
pcre2lib: Pull PCRE2 10.37
Excerpt from the release news: Version 10.37 26-May-2021 ------------------------- A few more bug fixes and tidies. The only change of real note is the removal of the actual POSIX names regcomp etc. from the POSIX wrapper library because these have caused issues for some applications (see 10.33 php#2 below). Version 10.36 04-December-2020 ------------------------------ Again, mainly bug fixes and tidies. The only enhancements are the addition of GNU grep's -m (aka --max-count) option to pcre2grep, and also unifying the handling of substitution strings for both -O and callouts in pcre2grep, with the addition of $x{...} and $o{...} to allow for characters whose code points are greater than 255 in Unicode mode. NOTE: there is an outstanding issue with JIT support for MacOS on arm64 hardware. For details, please see Bugzilla issue php#2618. Signed-off-by: Anatol Belski <[email protected]>
1 parent 56c1633 commit 5d42900

32 files changed

+4630
-13576
lines changed

ext/pcre/pcre2lib/pcre2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
4242
/* The current PCRE version information. */
4343

4444
#define PCRE2_MAJOR 10
45-
#define PCRE2_MINOR 35
45+
#define PCRE2_MINOR 37
4646
#define PCRE2_PRERELEASE
47-
#define PCRE2_DATE 2020-05-09
47+
#define PCRE2_DATE 2021-05-26
4848

4949
/* When an application links to a PCRE DLL in Windows, the symbols that are
5050
imported have to be identified as such. When building PCRE2, the appropriate

ext/pcre/pcre2lib/pcre2_auto_possess.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
77
88
Written by Philip Hazel
99
Original API code Copyright (c) 1997-2012 University of Cambridge
10-
New API code Copyright (c) 2016-2020 University of Cambridge
10+
New API code Copyright (c) 2016-2021 University of Cambridge
1111
1212
-----------------------------------------------------------------------------
1313
Redistribution and use in source and binary forms, with or without
@@ -490,6 +490,7 @@ switch(c)
490490
list[2] = (uint32_t)(end - code);
491491
return end;
492492
}
493+
493494
return NULL; /* Opcode not accepted */
494495
}
495496

@@ -1186,12 +1187,16 @@ for (;;)
11861187
c = *repeat_opcode;
11871188
if (c >= OP_CRSTAR && c <= OP_CRMINRANGE)
11881189
{
1189-
/* end must not be NULL. */
1190-
end = get_chr_property_list(code, utf, ucp, cb->fcc, list);
1190+
/* The return from get_chr_property_list() will never be NULL when
1191+
*code (aka c) is one of the three class opcodes. However, gcc with
1192+
-fanalyzer notes that a NULL return is possible, and grumbles. Hence we
1193+
put in a check. */
11911194

1195+
end = get_chr_property_list(code, utf, ucp, cb->fcc, list);
11921196
list[1] = (c & 1) == 0;
11931197

1194-
if (compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
1198+
if (end != NULL &&
1199+
compare_opcodes(end, utf, ucp, cb, list, end, &rec_limit))
11951200
{
11961201
switch (c)
11971202
{

ext/pcre/pcre2lib/pcre2_chartables.c

-202
This file was deleted.

ext/pcre/pcre2lib/pcre2_chartables.c

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/weltling/dws/src/pcre2-10.37/src/pcre2_chartables.c.dist

ext/pcre/pcre2lib/pcre2_compile.c

+37-18
Original file line numberDiff line numberDiff line change
@@ -1398,32 +1398,47 @@ static BOOL
13981398
read_repeat_counts(PCRE2_SPTR *ptrptr, PCRE2_SPTR ptrend, uint32_t *minp,
13991399
uint32_t *maxp, int *errorcodeptr)
14001400
{
1401-
PCRE2_SPTR p = *ptrptr;
1401+
PCRE2_SPTR p;
14021402
BOOL yield = FALSE;
1403+
BOOL had_comma = FALSE;
14031404
int32_t min = 0;
14041405
int32_t max = REPEAT_UNLIMITED; /* This value is larger than MAX_REPEAT_COUNT */
14051406

1406-
/* NB read_number() initializes the error code to zero. The only error is for a
1407-
number that is too big. */
1407+
/* Check the syntax */
14081408

1409+
*errorcodeptr = 0;
1410+
for (p = *ptrptr;; p++)
1411+
{
1412+
uint32_t c;
1413+
if (p >= ptrend) return FALSE;
1414+
c = *p;
1415+
if (IS_DIGIT(c)) continue;
1416+
if (c == CHAR_RIGHT_CURLY_BRACKET) break;
1417+
if (c == CHAR_COMMA)
1418+
{
1419+
if (had_comma) return FALSE;
1420+
had_comma = TRUE;
1421+
}
1422+
else return FALSE;
1423+
}
1424+
1425+
/* The only error from read_number() is for a number that is too big. */
1426+
1427+
p = *ptrptr;
14091428
if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &min, errorcodeptr))
14101429
goto EXIT;
14111430

1412-
if (p >= ptrend) goto EXIT;
1413-
14141431
if (*p == CHAR_RIGHT_CURLY_BRACKET)
14151432
{
14161433
p++;
14171434
max = min;
14181435
}
1419-
14201436
else
14211437
{
1422-
if (*p++ != CHAR_COMMA || p >= ptrend) goto EXIT;
1423-
if (*p != CHAR_RIGHT_CURLY_BRACKET)
1438+
if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
14241439
{
14251440
if (!read_number(&p, ptrend, -1, MAX_REPEAT_COUNT, ERR5, &max,
1426-
errorcodeptr) || p >= ptrend || *p != CHAR_RIGHT_CURLY_BRACKET)
1441+
errorcodeptr))
14271442
goto EXIT;
14281443
if (max < min)
14291444
{
@@ -1438,11 +1453,10 @@ yield = TRUE;
14381453
if (minp != NULL) *minp = (uint32_t)min;
14391454
if (maxp != NULL) *maxp = (uint32_t)max;
14401455

1441-
/* Update the pattern pointer on success, or after an error, but not when
1442-
the result is "not a repeat quantifier". */
1456+
/* Update the pattern pointer */
14431457

14441458
EXIT:
1445-
if (yield || *errorcodeptr != 0) *ptrptr = p;
1459+
*ptrptr = p;
14461460
return yield;
14471461
}
14481462

@@ -1776,19 +1790,23 @@ else
17761790
{
17771791
oldptr = ptr;
17781792
ptr--; /* Back to the digit */
1779-
if (!read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, ERR61, &s,
1780-
errorcodeptr))
1781-
break;
17821793

1783-
/* \1 to \9 are always back references. \8x and \9x are too; \1x to \7x
1794+
/* As we know we are at a digit, the only possible error from
1795+
read_number() is a number that is too large to be a group number. In this
1796+
case we fall through handle this as not a group reference. If we have
1797+
read a small enough number, check for a back reference.
1798+
1799+
\1 to \9 are always back references. \8x and \9x are too; \1x to \7x
17841800
are octal escapes if there are not that many previous captures. */
17851801

1786-
if (s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount)
1802+
if (read_number(&ptr, ptrend, -1, INT_MAX/10 - 1, 0, &s, errorcodeptr) &&
1803+
(s < 10 || oldptr[-1] >= CHAR_8 || s <= (int)cb->bracount))
17871804
{
17881805
if (s > (int)MAX_GROUP_NUMBER) *errorcodeptr = ERR61;
17891806
else escape = -s; /* Indicates a back reference */
17901807
break;
17911808
}
1809+
17921810
ptr = oldptr; /* Put the pointer back and fall through */
17931811
}
17941812

@@ -2344,7 +2362,7 @@ if (ptr > *nameptr + MAX_NAME_SIZE)
23442362
*errorcodeptr = ERR48;
23452363
goto FAILED;
23462364
}
2347-
*namelenptr = ptr - *nameptr;
2365+
*namelenptr = (uint32_t)(ptr - *nameptr);
23482366

23492367
/* Subpattern names must not be empty, and their terminator is checked here.
23502368
(What follows a verb or alpha assertion name is checked separately.) */
@@ -4331,6 +4349,7 @@ while (ptr < ptrend)
43314349
{
43324350
if (++ptr >= ptrend || !IS_DIGIT(*ptr)) goto BAD_VERSION_CONDITION;
43334351
minor = (*ptr++ - CHAR_0) * 10;
4352+
if (ptr >= ptrend) goto BAD_VERSION_CONDITION;
43344353
if (IS_DIGIT(*ptr)) minor += *ptr++ - CHAR_0;
43354354
if (ptr >= ptrend || *ptr != CHAR_RIGHT_PARENTHESIS)
43364355
goto BAD_VERSION_CONDITION;

0 commit comments

Comments
 (0)