Skip to content

Commit 8a287c0

Browse files
committed
Upgrade bundled PCRE to 8.41
HEADSUP! With PCRE 8.39 the JIT related code was changed in the way, that additional valgrind options became almost unavoidable. Valgrind had it already sometimes hard with JIT, now there are seem to be more cases requiring special valgrind options. For this reason, the new configure option --with-pcre-valgrind was introduced. The option is development/debugging only and turns on the Valgrind related pieces in PCRE, so then false positives are avoided to the big part. In addition, run-tests.php was added a new valgrind option, when the leak check is enabled and the test filepath contains pcre. Thus, to debug the code related to PCRE with JIT enabled, two things would likely make sense - configure --with-pcre-valgrind - valgrind option --smc-check=all if run-tests.php is not used The checks so far reveal no new issues.
1 parent 9bcd932 commit 8a287c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+11022
-8952
lines changed

ext/pcre/config0.m4

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,29 @@ PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality]
7878
fi
7979
fi
8080

81+
PHP_ARG_WITH(pcre-valgrind,,[ --with-pcre-valgrind=DIR
82+
Enable PCRE valgrind support. Developers only!], no, no)
83+
if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
84+
AC_MSG_WARN([PHP is going to be linked with an external PCRE, --with-pcre-valgrind has no effect])
85+
else
86+
if test "$PHP_PCRE_VALGRIND" != "no"; then
87+
PHP_PCRE_VALGRIND_INCDIR=
88+
AC_MSG_CHECKING([for Valgrind headers location])
89+
for i in $PHP_PCRE_VALGRIND $PHP_PCRE_VALGRIND/include $PHP_PCRE_VALGRIND/local/include /usr/include /usr/local/include; do
90+
if test -f $i/valgrind/memcheck.h
91+
then
92+
PHP_PCRE_VALGRIND_INCDIR=$i
93+
break
94+
fi
95+
done
96+
if test -z "$PHP_PCRE_VALGRIND_INCDIR"
97+
then
98+
AC_MSG_ERROR([Could not find valgrind/memcheck.h])
99+
else
100+
AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ])
101+
PHP_ADD_INCLUDE($PHP_PCRE_VALGRIND_INCDIR)
102+
AC_MSG_RESULT([$PHP_PCRE_VALGRIND_INCDIR])
103+
fi
104+
fi
105+
fi
106+

ext/pcre/pcrelib/AUTHORS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Email domain: cam.ac.uk
88
University of Cambridge Computing Service,
99
Cambridge, England.
1010

11-
Copyright (c) 1997-2015 University of Cambridge
11+
Copyright (c) 1997-2017 University of Cambridge
1212
All rights reserved
1313

1414

@@ -19,7 +19,7 @@ Written by: Zoltan Herczeg
1919
Email local part: hzmester
2020
Emain domain: freemail.hu
2121

22-
Copyright(c) 2010-2015 Zoltan Herczeg
22+
Copyright(c) 2010-2017 Zoltan Herczeg
2323
All rights reserved.
2424

2525

@@ -30,7 +30,7 @@ Written by: Zoltan Herczeg
3030
Email local part: hzmester
3131
Emain domain: freemail.hu
3232

33-
Copyright(c) 2009-2015 Zoltan Herczeg
33+
Copyright(c) 2009-2017 Zoltan Herczeg
3434
All rights reserved.
3535

3636

ext/pcre/pcrelib/ChangeLog

Lines changed: 187 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,198 @@ ChangeLog for PCRE
44
Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All
55
development is happening in the PCRE2 10.xx series.
66

7+
Version 8.41 05-July-2017
8+
-------------------------
9+
10+
1. Fixed typo in CMakeLists.txt (wrong number of arguments for
11+
PCRE_STATIC_RUNTIME (affects MSVC only).
12+
13+
2. Issue 1 for 8.40 below was not correctly fixed. If pcregrep in multiline
14+
mode with --only-matching matched several lines, it restarted scanning at the
15+
next line instead of moving on to the end of the matched string, which can be
16+
several lines after the start.
17+
18+
3. Fix a missing else in the JIT compiler reported by 'idaifish'.
19+
20+
4. A (?# style comment is now ignored between a basic quantifier and a
21+
following '+' or '?' (example: /X+(?#comment)?Y/.
22+
23+
5. Avoid use of a potentially overflowing buffer in pcregrep (patch by Petr
24+
Pisar).
25+
26+
6. Fuzzers have reported issues in pcretest. These are NOT serious (it is,
27+
after all, just a test program). However, to stop the reports, some easy ones
28+
are fixed:
29+
30+
(a) Check for values < 256 when calling isprint() in pcretest.
31+
(b) Give an error for too big a number after \O.
32+
33+
7. In the 32-bit library in non-UTF mode, an attempt to find a Unicode
34+
property for a character with a code point greater than 0x10ffff (the Unicode
35+
maximum) caused a crash.
36+
37+
8. The alternative matching function, pcre_dfa_exec() misbehaved if it
38+
encountered a character class with a possessive repeat, for example [a-f]{3}+.
39+
40+
9. When pcretest called pcre_copy_substring() in 32-bit mode, it set the buffer
41+
length incorrectly, which could result in buffer overflow.
42+
43+
10. Remove redundant line of code (accidentally left in ages ago).
44+
45+
11. Applied C++ patch from Irfan Adilovic to guard 'using std::' directives
46+
with namespace pcrecpp (Bugzilla #2084).
47+
48+
12. Remove a duplication typo in pcre_tables.c.
49+
50+
13. Fix returned offsets from regexec() when REG_STARTEND is used with a
51+
starting offset greater than zero.
52+
53+
54+
Version 8.40 11-January-2017
55+
----------------------------
56+
57+
1. Using -o with -M in pcregrep could cause unnecessary repeated output when
58+
the match extended over a line boundary.
59+
60+
2. Applied Chris Wilson's second patch (Bugzilla #1681) to CMakeLists.txt for
61+
MSVC static compilation, putting the first patch under a new option.
62+
63+
3. Fix register overwite in JIT when SSE2 acceleration is enabled.
64+
65+
4. Ignore "show all captures" (/=) for DFA matching.
66+
67+
5. Fix JIT unaligned accesses on x86. Patch by Marc Mutz.
68+
69+
6. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode),
70+
without PCRE_UCP set, a negative character type such as \D in a positive
71+
class should cause all characters greater than 255 to match, whatever else
72+
is in the class. There was a bug that caused this not to happen if a
73+
Unicode property item was added to such a class, for example [\D\P{Nd}] or
74+
[\W\pL].
75+
76+
7. When pcretest was outputing information from a callout, the caret indicator
77+
for the current position in the subject line was incorrect if it was after
78+
an escape sequence for a character whose code point was greater than
79+
\x{ff}.
80+
81+
8. A pattern such as (?<RA>abc)(?(R)xyz) was incorrectly compiled such that
82+
the conditional was interpreted as a reference to capturing group 1 instead
83+
of a test for recursion. Any group whose name began with R was
84+
misinterpreted in this way. (The reference interpretation should only
85+
happen if the group's name is precisely "R".)
86+
87+
9. A number of bugs have been mended relating to match start-up optimizations
88+
when the first thing in a pattern is a positive lookahead. These all
89+
applied only when PCRE_NO_START_OPTIMIZE was *not* set:
90+
91+
(a) A pattern such as (?=.*X)X$ was incorrectly optimized as if it needed
92+
both an initial 'X' and a following 'X'.
93+
(b) Some patterns starting with an assertion that started with .* were
94+
incorrectly optimized as having to match at the start of the subject or
95+
after a newline. There are cases where this is not true, for example,
96+
(?=.*[A-Z])(?=.{8,16})(?!.*[\s]) matches after the start in lines that
97+
start with spaces. Starting .* in an assertion is no longer taken as an
98+
indication of matching at the start (or after a newline).
99+
100+
101+
Version 8.39 14-June-2016
102+
-------------------------
103+
104+
1. If PCRE_AUTO_CALLOUT was set on a pattern that had a (?# comment between
105+
an item and its qualifier (for example, A(?#comment)?B) pcre_compile()
106+
misbehaved. This bug was found by the LLVM fuzzer.
107+
108+
2. Similar to the above, if an isolated \E was present between an item and its
109+
qualifier when PCRE_AUTO_CALLOUT was set, pcre_compile() misbehaved. This
110+
bug was found by the LLVM fuzzer.
111+
112+
3. Further to 8.38/46, negated classes such as [^[:^ascii:]\d] were also not
113+
working correctly in UCP mode.
114+
115+
4. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
116+
was set when the pmatch argument was NULL. It now returns REG_INVARG.
117+
118+
5. Allow for up to 32-bit numbers in the ordin() function in pcregrep.
119+
120+
6. An empty \Q\E sequence between an item and its qualifier caused
121+
pcre_compile() to misbehave when auto callouts were enabled. This bug was
122+
found by the LLVM fuzzer.
123+
124+
7. If a pattern that was compiled with PCRE_EXTENDED started with white
125+
space or a #-type comment that was followed by (?-x), which turns off
126+
PCRE_EXTENDED, and there was no subsequent (?x) to turn it on again,
127+
pcre_compile() assumed that (?-x) applied to the whole pattern and
128+
consequently mis-compiled it. This bug was found by the LLVM fuzzer.
129+
130+
8. A call of pcre_copy_named_substring() for a named substring whose number
131+
was greater than the space in the ovector could cause a crash.
132+
133+
9. Yet another buffer overflow bug involved duplicate named groups with a
134+
group that reset capture numbers (compare 8.38/7 below). Once again, I have
135+
just allowed for more memory, even if not needed. (A proper fix is
136+
implemented in PCRE2, but it involves a lot of refactoring.)
137+
138+
10. pcre_get_substring_list() crashed if the use of \K in a match caused the
139+
start of the match to be earlier than the end.
140+
141+
11. Migrating appropriate PCRE2 JIT improvements to PCRE.
142+
143+
12. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind
144+
assertion, caused pcretest to generate incorrect output, and also to read
145+
uninitialized memory (detected by ASAN or valgrind).
146+
147+
13. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
148+
nested set of parentheses of sufficient size caused an overflow of the
149+
compiling workspace (which was diagnosed, but of course is not desirable).
150+
151+
14. And yet another buffer overflow bug involving duplicate named groups, this
152+
time nested, with a nested back reference. Yet again, I have just allowed
153+
for more memory, because anything more needs all the refactoring that has
154+
been done for PCRE2. An example pattern that provoked this bug is:
155+
/((?J)(?'R'(?'R'(?'R'(?'R'(?'R'(?|(\k'R'))))))))/ and the bug was
156+
registered as CVE-2016-1283.
157+
158+
15. pcretest went into a loop if global matching was requested with an ovector
159+
size less than 2. It now gives an error message. This bug was found by
160+
afl-fuzz.
161+
162+
16. An invalid pattern fragment such as (?(?C)0 was not diagnosing an error
163+
("assertion expected") when (?(?C) was not followed by an opening
164+
parenthesis.
165+
166+
17. Fixed typo ("&&" for "&") in pcre_study(). Fortunately, this could not
167+
actually affect anything, by sheer luck.
168+
169+
18. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
170+
static compilation.
171+
172+
19. Modified the RunTest script to incorporate a valgrind suppressions file so
173+
that certain errors, provoked by the SSE2 instruction set when JIT is used,
174+
are ignored.
175+
176+
20. A racing condition is fixed in JIT reported by Mozilla.
177+
178+
21. Minor code refactor to avoid "array subscript is below array bounds"
179+
compiler warning.
180+
181+
22. Minor code refactor to avoid "left shift of negative number" warning.
182+
183+
23. Fix typo causing compile error when 16- or 32-bit JIT is compiled without
184+
UCP support.
185+
186+
24. Refactor to avoid compiler warnings in pcrecpp.cc.
187+
188+
25. Refactor to fix a typo in pcre_jit_test.c
189+
190+
26. Patch to support compiling pcrecpp.cc with Intel compiler.
191+
192+
7193
Version 8.38 23-November-2015
8194
-----------------------------
9195

10196
1. If a group that contained a recursive back reference also contained a
11197
forward reference subroutine call followed by a non-forward-reference
12-
subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
198+
subroutine call, for example /.((?2)(?R)\1)()/, pcre_compile() failed to
13199
compile correct code, leading to undefined behaviour or an internally
14200
detected error. This bug was discovered by the LLVM fuzzer.
15201

ext/pcre/pcrelib/LICENCE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Email domain: cam.ac.uk
2525
University of Cambridge Computing Service,
2626
Cambridge, England.
2727

28-
Copyright (c) 1997-2015 University of Cambridge
28+
Copyright (c) 1997-2017 University of Cambridge
2929
All rights reserved.
3030

3131

@@ -36,7 +36,7 @@ Written by: Zoltan Herczeg
3636
Email local part: hzmester
3737
Emain domain: freemail.hu
3838

39-
Copyright(c) 2010-2015 Zoltan Herczeg
39+
Copyright(c) 2010-2017 Zoltan Herczeg
4040
All rights reserved.
4141

4242

@@ -47,7 +47,7 @@ Written by: Zoltan Herczeg
4747
Email local part: hzmester
4848
Emain domain: freemail.hu
4949

50-
Copyright(c) 2009-2015 Zoltan Herczeg
50+
Copyright(c) 2009-2017 Zoltan Herczeg
5151
All rights reserved.
5252

5353

ext/pcre/pcrelib/NEWS

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
News about PCRE releases
22
------------------------
33

4+
Release 8.41 13-June-2017
5+
-------------------------
6+
7+
This is a bug-fix release.
8+
9+
10+
Release 8.40 11-January-2017
11+
----------------------------
12+
13+
This is a bug-fix release.
14+
15+
16+
Release 8.39 14-June-2016
17+
-------------------------
18+
19+
Some appropriate PCRE2 JIT improvements have been retro-fitted to PCRE1. Apart
20+
from that, this is another bug-fix release. Note that this library (now called
21+
PCRE1) is now being maintained for bug fixes only. New projects are advised to
22+
use the new PCRE2 libraries.
23+
24+
425
Release 8.38 23-November-2015
526
-----------------------------
627

ext/pcre/pcrelib/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ The "configure" script also creates config.status, which is an executable
442442
script that can be run to recreate the configuration, and config.log, which
443443
contains compiler output from tests that "configure" runs.
444444

445-
Once "configure" has run, you can run "make". This builds the libraries
445+
Once "configure" has run, you can run "make". This builds the the libraries
446446
libpcre, libpcre16 and/or libpcre32, and a test program called pcretest. If you
447447
enabled JIT support with --enable-jit, a test program called pcre_jit_test is
448448
built as well.

ext/pcre/pcrelib/config.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ them both to 0; an emulation function will be used. */
316316
#define PACKAGE_NAME "PCRE"
317317

318318
/* Define to the full name and version of this package. */
319-
#define PACKAGE_STRING "PCRE 8.38"
319+
#define PACKAGE_STRING "PCRE 8.41"
320320

321321
/* Define to the one symbol short name of this package. */
322322
#define PACKAGE_TARNAME "pcre"
@@ -325,7 +325,7 @@ them both to 0; an emulation function will be used. */
325325
#define PACKAGE_URL ""
326326

327327
/* Define to the version of this package. */
328-
#define PACKAGE_VERSION "8.38"
328+
#define PACKAGE_VERSION "8.41"
329329

330330
/* to make a symbol visible */
331331
/* #undef PCRECPP_EXP_DECL */
@@ -439,11 +439,13 @@ them both to 0; an emulation function will be used. */
439439
/* #undef SUPPORT_UTF8 */
440440

441441
/* Valgrind support to find invalid memory reads. */
442-
/* #undef SUPPORT_VALGRIND */
442+
#if HAVE_PCRE_VALGRIND_SUPPORT
443+
#define SUPPORT_VALGRIND 1
444+
#endif
443445

444446
/* Version number of package */
445447
#ifndef VERSION
446-
#define VERSION "8.38"
448+
#define VERSION "8.41"
447449
#endif
448450

449451
/* Define to empty if `const' does not conform to ANSI C. */

ext/pcre/pcrelib/dftables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ character tables for PCRE. The tables are built according to the current
4343
locale. Now that pcre_maketables is a function visible to the outside world, we
4444
make use of its code from here in order to be consistent. */
4545

46+
#ifdef HAVE_CONFIG_H
4647
#include "config.h"
48+
#endif
4749

4850
#include <ctype.h>
4951
#include <stdio.h>

0 commit comments

Comments
 (0)