blob: 66c6d0b3b0461af04fde4c70d4ed2cca690a3db3 [file] [log] [blame]
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001Change Log for PCRE2
2--------------------
3
Janis Danisevskis8b979b22016-08-15 16:09:16 +01004
Elliott Hughes0c26e192019-08-07 12:24:46 -07005Version 10.33 16-April-2019
6---------------------------
7
81. Added "allvector" to pcre2test to make it easy to check the part of the
9ovector that shouldn't be changed, in particular after substitute and failed or
10partial matches.
11
122. Fix subject buffer overread in JIT when UTF is disabled and \X or \R has
13a greater than 1 fixed quantifier. This issue was found by Yunho Kim.
14
153. Added support for callouts from pcre2_substitute(). After 10.33-RC1, but
16prior to release, fixed a bug that caused a crash if pcre2_substitute() was
17called with a NULL match context.
18
194. The POSIX functions are now all called pcre2_regcomp() etc., with wrapper
20functions that use the standard POSIX names. However, in pcre2posix.h the POSIX
21names are defined as macros. This should help avoid linking with the wrong
22library in some environments while still exporting the POSIX names for
23pre-existing programs that use them. (The Debian alternative names are also
24defined as macros, but not documented.)
25
265. Fix an xclass matching issue in JIT.
27
286. Implement PCRE2_EXTRA_ESCAPED_CR_IS_LF (see Bugzilla 2315).
29
307. Implement the Perl 5.28 experimental alphabetic names for atomic groups and
31lookaround assertions, for example, (*pla:...) and (*atomic:...). These are
32characterized by a lower case letter following (* and to simplify coding for
33this, the character tables created by pcre2_maketables() were updated to add a
34new "is lower case letter" bit. At the same time, the now unused "is
35hexadecimal digit" bit was removed. The default tables in
36src/pcre2_chartables.c.dist are updated.
37
388. Implement the new Perl "script run" features (*script_run:...) and
39(*atomic_script_run:...) aka (*sr:...) and (*asr:...).
40
419. Fixed two typos in change 22 for 10.21, which added special handling for
42ranges such as a-z in EBCDIC environments. The original code probably never
43worked, though there were no bug reports.
44
4510. Implement PCRE2_COPY_MATCHED_SUBJECT for pcre2_match() (including JIT via
46pcre2_match()) and pcre2_dfa_match(), but *not* the pcre2_jit_match() fast
47path. Also, when a match fails, set the subject field in the match data to NULL
48for tidiness - none of the substring extractors should reference this after
49match failure.
50
5111. If a pattern started with a subroutine call that had a quantifier with a
52minimum of zero, an incorrect "match must start with this character" could be
53recorded. Example: /(?&xxx)*ABC(?<xxx>XYZ)/ would (incorrectly) expect 'A' to
54be the first character of a match.
55
5612. The heap limit checking code in pcre2_dfa_match() could suffer from
57overflow if the heap limit was set very large. This could cause incorrect "heap
58limit exceeded" errors.
59
6013. Add "kibibytes" to the heap limit output from pcre2test -C to make the
61units clear.
62
6314. Add a call to pcre2_jit_free_unused_memory() in pcre2grep, for tidiness.
64
6515. Updated the VMS-specific code in pcre2test on the advice of a VMS user.
66
6716. Removed the unnecessary inclusion of stdint.h (or inttypes.h) from
68pcre2_internal.h as it is now included by pcre2.h. Also, change 17 for 10.32
69below was unnecessarily complicated, as inttypes.h is a Standard C header,
70which is defined to be a superset of stdint.h. Instead of conditionally
71including stdint.h or inttypes.h, pcre2.h now unconditionally includes
72inttypes.h. This supports environments that do not have stdint.h but do have
73inttypes.h, which are known to exist. A note in the autotools documentation
74says (November 2018) that there are none known that are the other way round.
75
7617. Added --disable-percent-zt to "configure" (and equivalent to CMake) to
77forcibly disable the use of %zu and %td in formatting strings because there is
78at least one version of VMS that claims to be C99 but does not support these
79modifiers.
80
8118. Added --disable-pcre2grep-callout-fork, which restricts the callout support
82in pcre2grep to the inbuilt echo facility. This may be useful in environments
83that do not support fork().
84
8519. Fix two instances of <= 0 being applied to unsigned integers (the VMS
86compiler complains).
87
8820. Added "fork" support for VMS to pcre2grep, for running an external program
89via a string callout.
90
9121. Improve MAP_JIT flag usage on MacOS. Patch by Rich Siegel.
92
9322. If a pattern started with (*MARK), (*COMMIT), (*PRUNE), (*SKIP), or (*THEN)
94followed by ^ it was not recognized as anchored.
95
9623. The RunGrepTest script used to cut out the test of NUL characters for
97Solaris and MacOS as printf and sed can't handle them. It seems that the *BSD
98systems can't either. I've inverted the test so that only those OS that are
99known to work (currently only Linux) try to run this test.
100
10124. Some tests in RunGrepTest appended to testtrygrep from two different file
102descriptors instead of redirecting stderr to stdout. This worked on Linux, but
103it was reported not to on other systems, causing the tests to fail.
104
10525. In the RunTest script, make the test for stack setting use the same value
106for the stack as it needs for -bigstack.
107
10826. Insert a cast in pcre2_dfa_match.c to suppress a compiler warning.
109
11026. With PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL set, escape sequences such as \s
111which are valid in character classes, but not as the end of ranges, were being
112treated as literals. An example is [_-\s] (but not [\s-_] because that gave an
113error at the *start* of a range). Now an "invalid range" error is given
114independently of PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
115
11627. Related to 26 above, PCRE2_BAD_ESCAPE_IS_LITERAL was affecting known escape
117sequences such as \eX when they appeared invalidly in a character class. Now
118the option applies only to unrecognized or malformed escape sequences.
119
12028. Fix word boundary in JIT compiler. Patch by Mike Munday.
121
12229. The pcre2_dfa_match() function was incorrectly handling conditional version
123tests such as (?(VERSION>=0)...) when the version test was true. Incorrect
124processing or a crash could result.
125
12630. When PCRE2_UTF is set, allow non-ASCII letters and decimal digits in group
127names, as Perl does. There was a small bug in this new code, found by
128ClusterFuzz 12950, fixed before release.
129
13031. Implemented PCRE2_EXTRA_ALT_BSUX to support ECMAScript 6's \u{hhh}
131construct.
132
13332. Compile \p{Any} to be the same as . in DOTALL mode, so that it benefits
134from auto-anchoring if \p{Any}* starts a pattern.
135
13633. Compile invalid UTF check in JIT test when only pcre32 is enabled.
137
13834. For some time now, CMake has been warning about the setting of policy
139CMP0026 to "OLD" in CmakeLists.txt, and hinting that the feature might be
140removed in a future version. A request for CMake expertise on the list produced
141no result, so I have now hacked CMakeLists.txt along the lines of some changes
142I found on the Internet. The new code no longer needs the policy setting, and
143it appears to work fine on Linux.
144
14535. Setting --enable-jit=auto for an out-of-tree build failed because the
146source directory wasn't in the search path for AC_TRY_COMPILE always. Patch
147from Ross Burton.
148
14936. Disable SSE2 JIT optimizations in x86 CPUs when SSE2 is not available.
150Patch by Guillem Jover.
151
15237. Changed expressions such as 1<<10 to 1u<<10 in many places because compiler
153warnings were reported.
154
15538. Using the clang compiler with sanitizing options causes runtime complaints
156about truncation for statments such as x = ~x when x is an 8-bit value; it
157seems to compute ~x as a 32-bit value. Changing such statements to x = 255 ^ x
158gets rid of the warnings. There were also two missing casts in pcre2test.
159
160
161Version 10.32 10-September-2018
162-------------------------------
Elliott Hughes653c2102019-01-09 15:41:36 -0800163
1641. When matching using the the REG_STARTEND feature of the POSIX API with a
165non-zero starting offset, unset capturing groups with lower numbers than a
166group that did capture something were not being correctly returned as "unset"
167(that is, with offset values of -1).
168
1692. When matching using the POSIX API, pcre2test used to omit listing unset
170groups altogether. Now it shows those that come before any actual captures as
171"<unset>", as happens for non-POSIX matching.
172
1733. Running "pcre2test -C" always stated "\R matches CR, LF, or CRLF only",
174whatever the build configuration was. It now correctly says "\R matches all
175Unicode newlines" in the default case when --enable-bsr-anycrlf has not been
176specified. Similarly, running "pcre2test -C bsr" never produced the result
177ANY.
178
1794. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string containing
180multi-code-unit characters caused bad behaviour and possibly a crash. This
181issue was fixed for other kinds of repeat in release 10.20 by change 19, but
182repeating character classes were overlooked.
183
1845. pcre2grep now supports the inclusion of binary zeros in patterns that are
185read from files via the -f option.
186
1876. A small fix to pcre2grep to avoid compiler warnings for -Wformat-overflow=2.
188
1897. Added --enable-jit=auto support to configure.ac.
190
1918. Added some dummy variables to the heapframe structure in 16-bit and 32-bit
192modes for the benefit of m68k, where pointers can be 16-bit aligned. The
193dummies force 32-bit alignment and this ensures that the structure is a
194multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
195architectures, alignment requirements take care of this automatically.
196
1979. When returning an error from pcre2_pattern_convert(), ensure the error
198offset is set zero for early errors.
199
20010. A number of patches for Windows support from Daniel Richard G:
201
202 (a) List of error numbers in Runtest.bat corrected (it was not the same as in
203 Runtest).
204
205 (b) pcre2grep snprintf() workaround as used elsewhere in the tree.
206
207 (c) Support for non-C99 snprintf() that returns -1 in the overflow case.
208
20911. Minor tidy of pcre2_dfa_match() code.
210
21112. Refactored pcre2_dfa_match() so that the internal recursive calls no longer
212use the stack for local workspace and local ovectors. Instead, an initial block
213of stack is reserved, but if this is insufficient, heap memory is used. The
214heap limit parameter now applies to pcre2_dfa_match().
215
21613. If a "find limits" test of DFA matching in pcre2test resulted in too many
217matches for the ovector, no matches were displayed.
218
21914. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as
220EOF. The test looks to have come from a fuzzer.
221
22215. If PCRE2 was built with a default match limit a lot greater than the
223default default of 10 000 000, some JIT tests of the match limit no longer
224failed. All such tests now set 10 000 000 as the upper limit.
225
22616. Another Windows related patch for pcregrep to ensure that WIN32 is
227undefined under Cygwin.
228
22917. Test for the presence of stdint.h and inttypes.h in configure and CMake and
230include whichever exists (stdint preferred) instead of unconditionally
231including stdint. This makes life easier for old and non-standard systems.
232
23318. Further changes to improve portability, especially to old and or non-
234standard systems:
235
236 (a) Put all printf arguments in RunGrepTest into single, not double, quotes,
237 and use \0 not \x00 for binary zero.
238
239 (b) Avoid the use of C++ (i.e. BCPL) // comments.
240
241 (c) Parameterize the use of %zu in pcre2test to make it like %td. For both of
242 these now, if using MSVC or a standard C before C99, %lu is used with a
243 cast if necessary.
244
24519. Applied a contributed patch to CMakeLists.txt to increase the stack size
246when linking pcre2test with MSVC. This gets rid of a stack overflow error in
247the standard set of tests.
248
24920. Output a warning in pcre2test when ignoring the "altglobal" modifier when
250it is given with the "replace" modifier.
251
25221. In both pcre2test and pcre2_substitute(), with global matching, a pattern
253that matched an empty string, but never at the starting match offset, was not
254handled in a Perl-compatible way. The pattern /(<?=\G.)/ is an example of such
255a pattern. Because \G is in a lookbehind assertion, there has to be a
256"bumpalong" before there can be a match. The automatic "advance by one
257character after an empty string match" rule is therefore inappropriate. A more
258complicated algorithm has now been implemented.
259
26022. When checking to see if a lookbehind is of fixed length, lookaheads were
261correctly ignored, but qualifiers on lookaheads were not being ignored, leading
262to an incorrect "lookbehind assertion is not fixed length" error.
263
26423. The VERSION condition test was reading fractional PCRE2 version numbers
265such as the 04 in 10.04 incorrectly and hence giving wrong results.
266
26724. Updated to Unicode version 11.0.0. As well as the usual addition of new
268scripts and characters, this involved re-jigging the grapheme break property
269algorithm because Unicode has changed the way emojis are handled.
270
27125. Fixed an obscure bug that struck when there were two atomic groups not
272separated by something with a backtracking point. There could be an incorrect
273backtrack into the first of the atomic groups. A complicated example is
274/(?>a(*:1))(?>b)(*SKIP:1)x|.*/ matched against "abc", where the *SKIP
275shouldn't find a MARK (because is in an atomic group), but it did.
276
27726. Upgraded the perltest.sh script: (1) #pattern lines can now be used to set
278a list of modifiers for all subsequent patterns - only those that the script
279recognizes are meaningful; (2) #subject lines can be used to set or unset a
280default "mark" modifier; (3) Unsupported #command lines give a warning when
281they are ignored; (4) Mark data is output only if the "mark" modifier is
282present.
283
28427. (*ACCEPT:ARG), (*FAIL:ARG), and (*COMMIT:ARG) are now supported.
285
28628. A (*MARK) name was not being passed back for positive assertions that were
287terminated by (*ACCEPT).
288
28929. Add support for \N{U+dddd}, but only in Unicode mode.
290
29130. Add support for (?^) for unsetting all imnsx options.
292
29331. The PCRE2_EXTENDED (/x) option only ever discarded space characters whose
294code point was less than 256 and that were recognized by the lookup table
295generated by pcre2_maketables(), which uses isspace() to identify white space.
296Now, when Unicode support is compiled, PCRE2_EXTENDED also discards U+0085,
297U+200E, U+200F, U+2028, and U+2029, which are additional characters defined by
298Unicode as "Pattern White Space". This makes PCRE2 compatible with Perl.
299
30032. In certain circumstances, option settings within patterns were not being
301correctly processed. For example, the pattern /((?i)A)(?m)B/ incorrectly
302matched "ab". (The (?m) setting lost the fact that (?i) should be reset at the
303end of its group during the parse process, but without another setting such as
304(?m) the compile phase got it right.) This bug was introduced by the
305refactoring in release 10.23.
306
30733. PCRE2 uses bcopy() if available when memmove() is not, and it used just to
308define memmove() as function call to bcopy(). This hasn't been tested for a
309long time because in pcre2test the result of memmove() was being used, whereas
310bcopy() doesn't return a result. This feature is now refactored always to call
311an emulation function when there is no memmove(). The emulation makes use of
312bcopy() when available.
313
31434. When serializing a pattern, set the memctl, executable_jit, and tables
315fields (that is, all the fields that contain pointers) to zeros so that the
316result of serializing is always the same. These fields are re-set when the
317pattern is deserialized.
318
31935. In a pattern such as /[^\x{100}-\x{ffff}]*[\x80-\xff]/ which has a repeated
320negative class with no characters less than 0x100 followed by a positive class
321with only characters less than 0x100, the first class was incorrectly being
322auto-possessified, causing incorrect match failures.
323
32436. Removed the character type bit ctype_meta, which dates from PCRE1 and is
325not used in PCRE2.
326
32737. Tidied up unnecessarily complicated macros used in the escapes table.
328
32938. Since 10.21, the new testoutput8-16-4 file has accidentally been omitted
330from distribution tarballs, owing to a typo in Makefile.am which had
331testoutput8-16-3 twice. Now fixed.
332
33339. If the only branch in a conditional subpattern was anchored, the whole
334subpattern was treated as anchored, when it should not have been, since the
335assumed empty second branch cannot be anchored. Demonstrated by test patterns
336such as /(?(1)^())b/ or /(?(?=^))b/.
337
33840. A repeated conditional subpattern that could match an empty string was
339always assumed to be unanchored. Now it it checked just like any other
340repeated conditional subpattern, and can be found to be anchored if the minimum
341quantifier is one or more. I can't see much use for a repeated anchored
342pattern, but the behaviour is now consistent.
343
34441. Minor addition to pcre2_jit_compile.c to avoid static analyzer complaint
345(for an event that could never occur but you had to have external information
346to know that).
347
34842. If before the first match in a file that was being searched by pcre2grep
349there was a line that was sufficiently long to cause the input buffer to be
350expanded, the variable holding the location of the end of the previous match
351was being adjusted incorrectly, and could cause an overflow warning from a code
352sanitizer. However, as the value is used only to print pending "after" lines
353when the next match is reached (and there are no such lines in this case) this
354bug could do no damage.
355
356
Elliott Hughes9bc971b2018-07-27 13:23:14 -0700357Version 10.31 12-February-2018
358------------------------------
359
3601. Fix typo (missing ]) in VMS code in pcre2test.c.
361
3622. Replace the replicated code for matching extended Unicode grapheme sequences
363(which got a lot more complicated by change 10.30/49) by a single subroutine
364that is called by both pcre2_match() and pcre2_dfa_match().
365
3663. Add idempotent guard to pcre2_internal.h.
367
3684. Add new pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and
369PCRE2_CONFIG_COMPILED_WIDTHS.
370
3715. Cut out \C tests in the JIT regression tests when NEVER_BACKSLASH_C is
372defined (e.g. by --enable-never-backslash-C).
373
3746. Defined public names for all the pcre2_compile() error numbers, and used
375the public names in pcre2_convert.c.
376
3777. Fixed a small memory leak in pcre2test (convert contexts).
378
3798. Added two casts to compile.c and one to match.c to avoid compiler warnings.
380
3819. Added code to pcre2grep when compiled under VMS to set the symbol
382PCRE2GREP_RC to the exit status, because VMS does not distinguish between
383exit(0) and exit(1).
384
38510. Added the -LM (list modifiers) option to pcre2test. Also made -C complain
386about a bad option only if the following argument item does not start with a
387hyphen.
388
38911. pcre2grep was truncating components of file names to 128 characters when
390processing files with the -r option, and also (some very odd code) truncating
391path names to 512 characters. There is now a check on the absolute length of
392full path file names, which may be up to 2047 characters long.
393
39412. When an assertion contained (*ACCEPT) it caused all open capturing groups
395to be closed (as for a non-assertion ACCEPT), which was wrong and could lead to
396misbehaviour for subsequent references to groups that started outside the
397assertion. ACCEPT in an assertion now closes only those groups that were
398started within that assertion. Fixes oss-fuzz issues 3852 and 3891.
399
40013. Multiline matching in pcre2grep was misbehaving if the pattern matched
401within a line, and then matched again at the end of the line and over into
402subsequent lines. Behaviour was different with and without colouring, and
403sometimes context lines were incorrectly printed and/or line endings were lost.
404All these issues should now be fixed.
405
40614. If --line-buffered was specified for pcre2grep when input was from a
407compressed file (.gz or .bz2) a segfault occurred. (Line buffering should be
408ignored for compressed files.)
409
41015. Although pcre2_jit_match checks whether the pattern is compiled
411in a given mode, it was also expected that at least one mode is available.
412This is fixed and pcre2_jit_match returns with PCRE2_ERROR_JIT_BADOPTION
413when the pattern is not optimized by JIT at all.
414
41516. The line number and related variables such as match counts in pcre2grep
416were all int variables, causing overflow when files with more than 2147483647
417lines were processed (assuming 32-bit ints). They have all been changed to
418unsigned long ints.
419
42017. If a backreference with a minimum repeat count of zero was first in a
421pattern, apart from assertions, an incorrect first matching character could be
422recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set
423as the first character of a match.
424
42518. Characters in a leading positive assertion are considered for recording a
426first character of a match when the rest of the pattern does not provide one.
427However, a character in a non-assertive group within a leading assertion such
428as in the pattern /(?=(a))\1?b/ caused this process to fail. This was an
429infelicity rather than an outright bug, because it did not affect the result of
430a match, just its speed. (In fact, in this case, the starting 'a' was
431subsequently picked up in the study.)
432
43319. A minor tidy in pcre2_match(): making all PCRE2_ERROR_ returns use "return"
434instead of "RRETURN" saves unwinding the backtracks in these cases (only one
435didn't).
436
43720. Allocate a single callout block on the stack at the start of pcre2_match()
438and set its never-changing fields once only. Do the same for pcre2_dfa_match().
439
44021. Save the extra compile options (set in the compile context) with the
441compiled pattern (they were not previously saved), add PCRE2_INFO_EXTRAOPTIONS
442to retrieve them, and update pcre2test to show them.
443
44422. Added PCRE2_CALLOUT_STARTMATCH and PCRE2_CALLOUT_BACKTRACK bits to a new
445field callout_flags in callout blocks. The bits are set by pcre2_match(), but
446not by JIT or pcre2_dfa_match(). Their settings are shown in pcre2test callouts
447if the callout_extra subject modifier is set. These bits are provided to help
448with tracking how a backtracking match is proceeding.
449
45023. Updated the pcre2demo.c demonstration program, which was missing the extra
451code for -g that handles the case when \K in an assertion causes the match to
452end at the original start point. Also arranged for it to detect when \K causes
453the end of a match to be before its start.
454
45524. Similar to 23 above, strange things (including loops) could happen in
456pcre2grep when \K was used in an assertion when --colour was used or in
457multiline mode. The "end at original start point" bug is fixed, and if the end
458point is found to be before the start point, they are swapped.
459
46025. When PCRE2_FIRSTLINE without PCRE2_NO_START_OPTIMIZE was used in non-JIT
461matching (both pcre2_match() and pcre2_dfa_match()) and the matched string
462started with the first code unit of a newline sequence, matching failed because
463it was not tried at the newline.
464
46526. Code for giving up a non-partial match after failing to find a starting
466code unit anywhere in the subject was missing when searching for one of a
467number of code units (the bitmap case) in both pcre2_match() and
468pcre2_dfa_match(). This was a missing optimization rather than a bug.
469
47027. Tidied up the ACROSSCHAR macro to be like FORWARDCHAR and BACKCHAR, using a
471pointer argument rather than a code unit value. This should not have affected
472the generated code.
473
47428. The JIT compiler has been updated.
475
47629. Avoid pointer overflow for unset captures in pcre2_substring_list_get().
477This could not actually cause a crash because it was always used in a memcpy()
478call with zero length.
479
48030. Some internal structures have a variable-length ovector[] as their last
481element. Their actual memory is obtained dynamically, giving an ovector of
482appropriate length. However, they are defined in the structure as
483ovector[NUMBER], where NUMBER is large so that array bound checkers don't
484grumble. The value of NUMBER was 10000, but a fuzzer exceeded 5000 capturing
485groups, making the ovector larger than this. The number has been increased to
486131072, which allows for the maximum number of captures (65535) plus the
487overall match. This fixes oss-fuzz issue 5415.
488
48931. Auto-possessification at the end of a capturing group was dependent on what
490follows the group (e.g. /(a+)b/ would auto-possessify the a+) but this caused
491incorrect behaviour when the group was called recursively from elsewhere in the
492pattern where something different might follow. This bug is an unforseen
493consequence of change #1 for 10.30 - the implementation of backtracking into
494recursions. Iterators at the ends of capturing groups are no longer considered
495for auto-possessification if the pattern contains any recursions. Fixes
496Bugzilla #2232.
497
498
499Version 10.30 14-August-2017
500----------------------------
501
5021. The main interpreter, pcre2_match(), has been refactored into a new version
503that does not use recursive function calls (and therefore the stack) for
504remembering backtracking positions. This makes --disable-stack-for-recursion a
505NOOP. The new implementation allows backtracking into recursive group calls in
506patterns, making it more compatible with Perl, and also fixes some other
507hard-to-do issues such as #1887 in Bugzilla. The code is also cleaner because
508the old code had a number of fudges to try to reduce stack usage. It seems to
509run no slower than the old code.
510
511A number of bugs in the refactored code were subsequently fixed during testing
512before release, but after the code was made available in the repository. These
513bugs were never in fully released code, but are noted here for the record.
514
515 (a) If a pattern had fewer capturing parentheses than the ovector supplied in
516 the match data block, a memory error (detectable by ASAN) occurred after
517 a match, because the external block was being set from non-existent
518 internal ovector fields. Fixes oss-fuzz issue 781.
519
520 (b) A pattern with very many capturing parentheses (when the internal frame
521 size was greater than the initial frame vector on the stack) caused a
522 crash. A vector on the heap is now set up at the start of matching if the
523 vector on the stack is not big enough to handle at least 10 frames.
524 Fixes oss-fuzz issue 783.
525
526 (c) Handling of (*VERB)s in recursions was wrong in some cases.
527
528 (d) Captures in negative assertions that were used as conditions were not
529 happening if the assertion matched via (*ACCEPT).
530
531 (e) Mark values were not being passed out of recursions.
532
533 (f) Refactor some code in do_callout() to avoid picky compiler warnings about
534 negative indices. Fixes oss-fuzz issue 1454.
535
536 (g) Similarly refactor the way the variable length ovector is addressed for
537 similar reasons. Fixes oss-fuzz issue 1465.
538
5392. Now that pcre2_match() no longer uses recursive function calls (see above),
540the "match limit recursion" value seems misnamed. It still exists, and limits
541the depth of tree that is searched. To avoid future confusion, it has been
542renamed as "depth limit" in all relevant places (--with-depth-limit,
543(*LIMIT_DEPTH), pcre2_set_depth_limit(), etc) but the old names are still
544available for backwards compatibility.
545
5463. Hardened pcre2test so as to reduce the number of bugs reported by fuzzers:
547
548 (a) Check for malloc failures when getting memory for the ovector (POSIX) or
549 the match data block (non-POSIX).
550
5514. In the 32-bit library in non-UTF mode, an attempt to find a Unicode property
552for a character with a code point greater than 0x10ffff (the Unicode maximum)
553caused a crash.
554
5555. If a lookbehind assertion that contained a back reference to a group
556appearing later in the pattern was compiled with the PCRE2_ANCHORED option,
557undefined actions (often a segmentation fault) could occur, depending on what
558other options were set. An example assertion is (?<!\1(abc)) where the
559reference \1 precedes the group (abc). This fixes oss-fuzz issue 865.
560
5616. Added the PCRE2_INFO_FRAMESIZE item to pcre2_pattern_info() and arranged for
562pcre2test to use it to output the frame size when the "framesize" modifier is
563given.
564
5657. Reworked the recursive pattern matching in the JIT compiler to follow the
566interpreter changes.
567
5688. When the zero_terminate modifier was specified on a pcre2test subject line
569for global matching, unpredictable things could happen. For example, in UTF-8
570mode, the pattern //g,zero_terminate read random memory when matched against an
571empty string with zero_terminate. This was a bug in pcre2test, not the library.
572
5739. Moved some Windows-specific code in pcre2grep (introduced in 10.23/13) out
574of the section that is compiled when Unix-style directory scanning is
575available, and into a new section that is always compiled for Windows.
576
57710. In pcre2test, explicitly close the file after an error during serialization
578or deserialization (the "load" or "save" commands).
579
58011. Fix memory leak in pcre2_serialize_decode() when the input is invalid.
581
58212. Fix potential NULL dereference in pcre2_callout_enumerate() if called with
583a NULL pattern pointer when Unicode support is available.
584
58513. When the 32-bit library was being tested by pcre2test, error messages that
586were longer than 64 code units could cause a buffer overflow. This was a bug in
587pcre2test.
588
58914. The alternative matching function, pcre2_dfa_match() misbehaved if it
590encountered a character class with a possessive repeat, for example [a-f]{3}+.
591
59215. The depth (formerly recursion) limit now applies to DFA matching (as
593of 10.23/36); pcre2test has been upgraded so that \=find_limits works with DFA
594matching to find the minimum value for this limit.
595
59616. Since 10.21, if pcre2_match() was called with a null context, default
597memory allocation functions were used instead of whatever was used when the
598pattern was compiled.
599
60017. Changes to the pcre2test "memory" modifier on a subject line. These apply
601only to pcre2_match():
602
603 (a) Warn if null_context is set on both pattern and subject, because the
604 memory details cannot then be shown.
605
606 (b) Remember (up to a certain number of) memory allocations and their
607 lengths, and list only the lengths, so as to be system-independent.
608 (In practice, the new interpreter never has more than 2 blocks allocated
609 simultaneously.)
610
61118. Make pcre2test detect an error return from pcre2_get_error_message(), give
612a message, and abandon the run (this would have detected #13 above).
613
61419. Implemented PCRE2_ENDANCHORED.
615
61620. Applied Jason Hood's patches (slightly modified) to pcre2grep, to implement
617the --output=text (-O) option and the inbuilt callout echo.
618
61921. Extend auto-anchoring etc. to ignore groups with a zero qualifier and
620single-branch conditions with a false condition (e.g. DEFINE) at the start of a
621branch. For example, /(?(DEFINE)...)^A/ and /(...){0}^B/ are now flagged as
622anchored.
623
62422. Added an explicit limit on the amount of heap used by pcre2_match(), set by
625pcre2_set_heap_limit() or (*LIMIT_HEAP=xxx). Upgraded pcre2test to show the
626heap limit along with other pattern information, and to find the minimum when
627the find_limits modifier is set.
628
62923. Write to the last 8 bytes of the pcre2_real_code structure when a compiled
630pattern is set up so as to initialize any padding the compiler might have
631included. This avoids valgrind warnings when a compiled pattern is copied, in
632particular when it is serialized.
633
63424. Remove a redundant line of code left in accidentally a long time ago.
635
63625. Remove a duplication typo in pcre2_tables.c
637
63826. Correct an incorrect cast in pcre2_valid_utf.c
639
64027. Update pcre2test, remove some unused code in pcre2_match(), and upgrade the
641tests to improve coverage.
642
64328. Some fixes/tidies as a result of looking at Coverity Scan output:
644
645 (a) Typo: ">" should be ">=" in opcode check in pcre2_auto_possess.c.
646 (b) Added some casts to avoid "suspicious implicit sign extension".
647 (c) Resource leaks in pcre2test in rare error cases.
648 (d) Avoid warning for never-use case OP_TABLE_LENGTH which is just a fudge
649 for checking at compile time that tables are the right size.
650 (e) Add missing "fall through" comment.
651
65229. Implemented PCRE2_EXTENDED_MORE and related /xx and (?xx) features.
653
65430. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
655
65631. If more than one of "push", "pushcopy", or "pushtablescopy" were set in
657pcre2test, a crash could occur.
658
Elliott Hughes653c2102019-01-09 15:41:36 -080065932. Make -bigstack in RunTest allocate a 64MiB stack (instead of 16MiB) so
660that all the tests can run with clang's sanitizing options.
Elliott Hughes9bc971b2018-07-27 13:23:14 -0700661
66233. Implement extra compile options in the compile context and add the first
663one: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES.
664
66534. Implement newline type PCRE2_NEWLINE_NUL.
666
66735. A lookbehind assertion that had a zero-length branch caused undefined
668behaviour when processed by pcre2_dfa_match(). This is oss-fuzz issue 1859.
669
67036. The match limit value now also applies to pcre2_dfa_match() as there are
671patterns that can use up a lot of resources without necessarily recursing very
672deeply. (Compare item 10.23/36.) This should fix oss-fuzz #1761.
673
67437. Implement PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
675
67638. Fix returned offsets from regexec() when REG_STARTEND is used with a
677starting offset greater than zero.
678
67939. Implement REG_PEND (GNU extension) for the POSIX wrapper.
680
68140. Implement the subject_literal modifier in pcre2test, and allow jitstack on
682pattern lines.
683
68441. Implement PCRE2_LITERAL and use it to support REG_NOSPEC.
685
68642. Implement PCRE2_EXTRA_MATCH_LINE and PCRE2_EXTRA_MATCH_WORD for the benefit
687of pcre2grep.
688
68943. Re-implement pcre2grep's -F, -w, and -x options using PCRE2_LITERAL,
690PCRE2_EXTRA_MATCH_WORD, and PCRE2_EXTRA_MATCH_LINE. This fixes two bugs:
691
692 (a) The -F option did not work for fixed strings containing \E.
693 (b) The -w option did not work for patterns with multiple branches.
694
69544. Added configuration options for the SELinux compatible execmem allocator in
696JIT.
697
69845. Increased the limit for searching for a "must be present" code unit in
699subjects from 1000 to 2000 for 8-bit searches, since they use memchr() and are
700much faster.
701
70246. Arrange for anchored patterns to record and use "first code unit" data,
703because this can give a fast "no match" without searching for a "required code
704unit". Previously only non-anchored patterns did this.
705
70647. Upgraded the Unicode tables from Unicode 8.0.0 to Unicode 10.0.0.
707
70848. Add the callout_no_where modifier to pcre2test.
709
71049. Update extended grapheme breaking rules to the latest set that are in
711Unicode Standard Annex #29.
712
71350. Added experimental foreign pattern conversion facilities
714(pcre2_pattern_convert() and friends).
715
71651. Change the macro FWRITE, used in pcre2grep, to FWRITE_IGNORE because FWRITE
717is defined in a system header in cygwin. Also modified some of the #ifdefs in
718pcre2grep related to Windows and Cygwin support.
719
72052. Change 3(g) for 10.23 was a bit too zealous. If a hyphen that follows a
721character class is the last character in the class, Perl does not give a
722warning. PCRE2 now also treats this as a literal.
723
72453. Related to 52, though PCRE2 was throwing an error for [[:digit:]-X] it was
725not doing so for [\d-X] (and similar escapes), as is documented.
726
72754. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard.
728
72955. Fixed a "maybe uninitialized" warning for class_uchardata in \p handling in
730pcre2_compile() which could never actually trigger (code should have been cut
731out when Unicode support is disabled).
732
733
734Version 10.23 14-February-2017
735------------------------------
736
7371. Extended pcre2test with the utf8_input modifier so that it is able to
738generate all possible 16-bit and 32-bit code unit values in non-UTF modes.
739
7402. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode), without
741PCRE2_UCP set, a negative character type such as \D in a positive class should
742cause all characters greater than 255 to match, whatever else is in the class.
743There was a bug that caused this not to happen if a Unicode property item was
744added to such a class, for example [\D\P{Nd}] or [\W\pL].
745
7463. There has been a major re-factoring of the pcre2_compile.c file. Most syntax
747checking is now done in the pre-pass that identifies capturing groups. This has
748reduced the amount of duplication and made the code tidier. While doing this,
749some minor bugs and Perl incompatibilities were fixed, including:
750
751 (a) \Q\E in the middle of a quantifier such as A+\Q\E+ is now ignored instead
752 of giving an invalid quantifier error.
753
754 (b) {0} can now be used after a group in a lookbehind assertion; previously
755 this caused an "assertion is not fixed length" error.
756
757 (c) Perl always treats (?(DEFINE) as a "define" group, even if a group with
758 the name "DEFINE" exists. PCRE2 now does likewise.
759
760 (d) A recursion condition test such as (?(R2)...) must now refer to an
761 existing subpattern.
762
763 (e) A conditional recursion test such as (?(R)...) misbehaved if there was a
764 group whose name began with "R".
765
766 (f) When testing zero-terminated patterns under valgrind, the terminating
767 zero is now marked "no access". This catches bugs that would otherwise
768 show up only with non-zero-terminated patterns.
769
770 (g) A hyphen appearing immediately after a POSIX character class (for example
771 /[[:ascii:]-z]/) now generates an error. Perl does accept this as a
772 literal, but gives a warning, so it seems best to fail it in PCRE.
773
774 (h) An empty \Q\E sequence may appear after a callout that precedes an
775 assertion condition (it is, of course, ignored).
776
777One effect of the refactoring is that some error numbers and messages have
778changed, and the pattern offset given for compiling errors is not always the
779right-most character that has been read. In particular, for a variable-length
780lookbehind assertion it now points to the start of the assertion. Another
781change is that when a callout appears before a group, the "length of next
782pattern item" that is passed now just gives the length of the opening
783parenthesis item, not the length of the whole group. A length of zero is now
784given only for a callout at the end of the pattern. Automatic callouts are no
785longer inserted before and after explicit callouts in the pattern.
786
787A number of bugs in the refactored code were subsequently fixed during testing
788before release, but after the code was made available in the repository. Many
789of the bugs were discovered by fuzzing testing. Several of them were related to
790the change from assuming a zero-terminated pattern (which previously had
791required non-zero terminated strings to be copied). These bugs were never in
792fully released code, but are noted here for the record.
793
794 (a) An overall recursion such as (?0) inside a lookbehind assertion was not
795 being diagnosed as an error.
796
797 (b) In utf mode, the length of a *MARK (or other verb) name was being checked
798 in characters instead of code units, which could lead to bad code being
799 compiled, leading to unpredictable behaviour.
800
801 (c) In extended /x mode, characters whose code was greater than 255 caused
802 a lookup outside one of the global tables. A similar bug existed for wide
803 characters in *VERB names.
804
805 (d) The amount of memory needed for a compiled pattern was miscalculated if a
806 lookbehind contained more than one toplevel branch and the first branch
807 was of length zero.
808
809 (e) In UTF-8 or UTF-16 modes with PCRE2_EXTENDED (/x) set and a non-zero-
810 terminated pattern, if a # comment ran on to the end of the pattern, one
811 or more code units past the end were being read.
812
813 (f) An unterminated repeat at the end of a non-zero-terminated pattern (e.g.
814 "{2,2") could cause reading beyond the pattern.
815
816 (g) When reading a callout string, if the end delimiter was at the end of the
817 pattern one further code unit was read.
818
819 (h) An unterminated number after \g' could cause reading beyond the pattern.
820
821 (i) An insufficient memory size was being computed for compiling with
822 PCRE2_AUTO_CALLOUT.
823
824 (j) A conditional group with an assertion condition used more memory than was
825 allowed for it during parsing, so too many of them could therefore
826 overrun a buffer.
827
828 (k) If parsing a pattern exactly filled the buffer, the internal test for
829 overrun did not check when the final META_END item was added.
830
831 (l) If a lookbehind contained a subroutine call, and the called group
832 contained an option setting such as (?s), and the PCRE2_ANCHORED option
833 was set, unpredictable behaviour could occur. The underlying bug was
834 incorrect code and insufficient checking while searching for the end of
835 the called subroutine in the parsed pattern.
836
837 (m) Quantifiers following (*VERB)s were not being diagnosed as errors.
838
839 (n) The use of \Q...\E in a (*VERB) name when PCRE2_ALT_VERBNAMES and
840 PCRE2_AUTO_CALLOUT were both specified caused undetermined behaviour.
841
842 (o) If \Q was preceded by a quantified item, and the following \E was
843 followed by '?' or '+', and there was at least one literal character
844 between them, an internal error "unexpected repeat" occurred (example:
845 /.+\QX\E+/).
846
847 (p) A buffer overflow could occur while sorting the names in the group name
848 list (depending on the order in which the names were seen).
849
850 (q) A conditional group that started with a callout was not doing the right
851 check for a following assertion, leading to compiling bad code. Example:
852 /(?(C'XX))?!XX/
853
854 (r) If a character whose code point was greater than 0xffff appeared within
855 a lookbehind that was within another lookbehind, the calculation of the
856 lookbehind length went wrong and could provoke an internal error.
857
858 (t) The sequence \E- or \Q\E- after a POSIX class in a character class caused
859 an internal error. Now the hyphen is treated as a literal.
860
8614. Back references are now permitted in lookbehind assertions when there are
862no duplicated group numbers (that is, (?| has not been used), and, if the
863reference is by name, there is only one group of that name. The referenced
864group must, of course be of fixed length.
865
8665. pcre2test has been upgraded so that, when run under valgrind with valgrind
867support enabled, reading past the end of the pattern is detected, both when
868compiling and during callout processing.
869
8706. \g{+<number>} (e.g. \g{+2} ) is now supported. It is a "forward back
871reference" and can be useful in repetitions (compare \g{-<number>} ). Perl does
872not recognize this syntax.
873
8747. Automatic callouts are no longer generated before and after callouts in the
875pattern.
876
8778. When pcre2test was outputing information from a callout, the caret indicator
878for the current position in the subject line was incorrect if it was after an
879escape sequence for a character whose code point was greater than \x{ff}.
880
8819. Change 19 for 10.22 had a typo (PCRE_STATIC_RUNTIME should be
882PCRE2_STATIC_RUNTIME). Fix from David Gaussmann.
883
88410. Added --max-buffer-size to pcre2grep, to allow for automatic buffer
885expansion when long lines are encountered. Original patch by Dmitry
886Cherniachenko.
887
88811. If pcre2grep was compiled with JIT support, but the library was compiled
889without it (something that neither ./configure nor CMake allow, but it can be
890done by editing config.h), pcre2grep was giving a JIT error. Now it detects
891this situation and does not try to use JIT.
892
89312. Added some "const" qualifiers to variables in pcre2grep.
894
89513. Added Dmitry Cherniachenko's patch for colouring output in Windows
896(untested by me). Also, look for GREP_COLOUR or GREP_COLOR if the environment
897variables PCRE2GREP_COLOUR and PCRE2GREP_COLOR are not found.
898
89914. Add the -t (grand total) option to pcre2grep.
900
90115. A number of bugs have been mended relating to match start-up optimizations
902when the first thing in a pattern is a positive lookahead. These all applied
903only when PCRE2_NO_START_OPTIMIZE was *not* set:
904
905 (a) A pattern such as (?=.*X)X$ was incorrectly optimized as if it needed
906 both an initial 'X' and a following 'X'.
907 (b) Some patterns starting with an assertion that started with .* were
908 incorrectly optimized as having to match at the start of the subject or
909 after a newline. There are cases where this is not true, for example,
910 (?=.*[A-Z])(?=.{8,16})(?!.*[\s]) matches after the start in lines that
911 start with spaces. Starting .* in an assertion is no longer taken as an
912 indication of matching at the start (or after a newline).
913
91416. The "offset" modifier in pcre2test was not being ignored (as documented)
915when the POSIX API was in use.
916
91717. Added --enable-fuzz-support to "configure", causing an non-installed
918library containing a test function that can be called by fuzzers to be
919compiled. A non-installed binary to run the test function locally, called
920pcre2fuzzcheck is also compiled.
921
92218. A pattern with PCRE2_DOTALL (/s) set but not PCRE2_NO_DOTSTAR_ANCHOR, and
923which started with .* inside a positive lookahead was incorrectly being
924compiled as implicitly anchored.
925
92619. Removed all instances of "register" declarations, as they are considered
927obsolete these days and in any case had become very haphazard.
928
92920. Add strerror() to pcre2test for failed file opening.
930
93121. Make pcre2test -C list valgrind support when it is enabled.
932
93322. Add the use_length modifier to pcre2test.
934
93523. Fix an off-by-one bug in pcre2test for the list of names for 'get' and
936'copy' modifiers.
937
93824. Add PCRE2_CALL_CONVENTION into the prototype declarations in pcre2.h as it
939is apparently needed there as well as in the function definitions. (Why did
940nobody ask for this in PCRE1?)
941
94225. Change the _PCRE2_H and _PCRE2_UCP_H guard macros in the header files to
943PCRE2_H_IDEMPOTENT_GUARD and PCRE2_UCP_H_IDEMPOTENT_GUARD to be more standard
944compliant and unique.
945
94626. pcre2-config --libs-posix was listing -lpcre2posix instead of
947-lpcre2-posix. Also, the CMake build process was building the library with the
948wrong name.
949
95027. In pcre2test, give some offset information for errors in hex patterns.
951This uses the C99 formatting sequence %td, except for MSVC which doesn't
952support it - %lu is used instead.
953
95428. Implemented pcre2_code_copy_with_tables(), and added pushtablescopy to
955pcre2test for testing it.
956
95729. Fix small memory leak in pcre2test.
958
95930. Fix out-of-bounds read for partial matching of /./ against an empty string
960when the newline type is CRLF.
961
96231. Fix a bug in pcre2test that caused a crash when a locale was set either in
963the current pattern or a previous one and a wide character was matched.
964
96532. The appearance of \p, \P, or \X in a substitution string when
966PCRE2_SUBSTITUTE_EXTENDED was set caused a segmentation fault (NULL
967dereference).
968
96933. If the starting offset was specified as greater than the subject length in
970a call to pcre2_substitute() an out-of-bounds memory reference could occur.
971
97234. When PCRE2 was compiled to use the heap instead of the stack for recursive
973calls to match(), a repeated minimizing caseless back reference, or a
974maximizing one where the two cases had different numbers of code units,
975followed by a caseful back reference, could lose the caselessness of the first
976repeated back reference (example: /(Z)(a)\2{1,2}?(?-i)\1X/i should match ZaAAZX
977but didn't).
978
97935. When a pattern is too complicated, PCRE2 gives up trying to find a minimum
980matching length and just records zero. Typically this happens when there are
981too many nested or recursive back references. If the limit was reached in
982certain recursive cases it failed to be triggered and an internal error could
983be the result.
984
98536. The pcre2_dfa_match() function now takes note of the recursion limit for
986the internal recursive calls that are used for lookrounds and recursions within
987the pattern.
988
98937. More refactoring has got rid of the internal could_be_empty_branch()
990function (around 400 lines of code, including comments) by keeping track of
991could-be-emptiness as the pattern is compiled instead of scanning compiled
992groups. (This would have been much harder before the refactoring of #3 above.)
993This lifts a restriction on the number of branches in a group (more than about
9941100 would give "pattern is too complicated").
995
99638. Add the "-ac" command line option to pcre2test as a synonym for "-pattern
997auto_callout".
998
99939. In a library with Unicode support, incorrect data was compiled for a
1000pattern with PCRE2_UCP set without PCRE2_UTF if a class required all wide
1001characters to match (for example, /[\s[:^ascii:]]/).
1002
100340. The callout_error modifier has been added to pcre2test to make it possible
1004to return PCRE2_ERROR_CALLOUT from a callout.
1005
100641. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of
1007"<esc>[00m".
1008
100942. The limit in the auto-possessification code that was intended to catch
1010overly-complicated patterns and not spend too much time auto-possessifying was
1011being reset too often, resulting in very long compile times for some patterns.
1012Now such patterns are no longer completely auto-possessified.
1013
101443. Applied Jason Hood's revised patch for RunTest.bat.
1015
101644. Added a new Windows script RunGrepTest.bat, courtesy of Jason Hood.
1017
101845. Minor cosmetic fix to pcre2test: move a variable that is not used under
1019Windows into the "not Windows" code.
1020
102146. Applied Jason Hood's patches to upgrade pcre2grep under Windows and tidy
1022some of the code:
1023
1024 * normalised the Windows condition by ensuring WIN32 is defined;
1025 * enables the callout feature under Windows;
1026 * adds globbing (Microsoft's implementation expands quoted args),
1027 using a tweaked opendirectory;
1028 * implements the is_*_tty functions for Windows;
1029 * --color=always will write the ANSI sequences to file;
1030 * add sequences 4 (underline works on Win10) and 5 (blink as bright
1031 background, relatively standard on DOS/Win);
1032 * remove the (char *) casts for the now-const strings;
1033 * remove GREP_COLOUR (grep's command line allowed the 'u', but not
1034 the environment), parsing GREP_COLORS instead;
1035 * uses the current colour if not set, rather than black;
1036 * add print_match for the undefined case;
1037 * fixes a typo.
1038
1039In addition, colour settings containing anything other than digits and
1040semicolon are ignored, and the colour controls are no longer output for empty
1041strings.
1042
104347. Detecting patterns that are too large inside the length-measuring loop
1044saves processing ridiculously long patterns to their end.
1045
104648. Ignore PCRE2_CASELESS when processing \h, \H, \v, and \V in classes as it
1047just wastes time. In the UTF case it can also produce redundant entries in
1048XCLASS lists caused by characters with multiple other cases and pairs of
1049characters in the same "not-x" sublists.
1050
105149. A pattern such as /(?=(a\K))/ can report the end of the match being before
1052its start; pcre2test was not handling this correctly when using the POSIX
1053interface (it was OK with the native interface).
1054
105550. In pcre2grep, ignore all JIT compile errors. This means that pcre2grep will
1056continue to work, falling back to interpretation if anything goes wrong with
1057JIT.
1058
105951. Applied patches from Christian Persch to configure.ac to make use of the
1060AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT
1061modules.
1062
106352. Minor fixes to pcre2grep from Jason Hood:
1064 * fixed some spacing;
1065 * Windows doesn't usually use single quotes, so I've added a define
1066 to use appropriate quotes [in an example];
1067 * LC_ALL was displayed as "LCC_ALL";
1068 * numbers 11, 12 & 13 should end in "th";
1069 * use double quotes in usage message.
1070
107153. When autopossessifying, skip empty branches without recursion, to reduce
1072stack usage for the benefit of clang with -fsanitize-address, which uses huge
1073stack frames. Example pattern: /X?(R||){3335}/. Fixes oss-fuzz issue 553.
1074
107554. A pattern with very many explicit back references to a group that is a long
1076way from the start of the pattern could take a long time to compile because
1077searching for the referenced group in order to find the minimum length was
1078being done repeatedly. Now up to 128 group minimum lengths are cached and the
1079attempt to find a minimum length is abandoned if there is a back reference to a
1080group whose number is greater than 128. (In that case, the pattern is so
1081complicated that this optimization probably isn't worth it.) This fixes
1082oss-fuzz issue 557.
1083
108455. Issue 32 for 10.22 below was not correctly fixed. If pcre2grep in multiline
1085mode with --only-matching matched several lines, it restarted scanning at the
1086next line instead of moving on to the end of the matched string, which can be
1087several lines after the start.
1088
108956. Applied Jason Hood's new patch for RunGrepTest.bat that updates it in line
1090with updates to the non-Windows version.
1091
1092
1093
Janis Danisevskis8b979b22016-08-15 16:09:16 +01001094Version 10.22 29-July-2016
1095--------------------------
1096
10971. Applied Jason Hood's patches to RunTest.bat and testdata/wintestoutput3
1098to fix problems with running the tests under Windows.
1099
11002. Implemented a facility for quoting literal characters within hexadecimal
1101patterns in pcre2test, to make it easier to create patterns with just a few
1102non-printing characters.
1103
11043. Binary zeros are not supported in pcre2test input files. It now detects them
1105and gives an error.
1106
11074. Updated the valgrind parameters in RunTest: (a) changed smc-check=all to
1108smc-check=all-non-file; (b) changed obj:* in the suppression file to obj:??? so
1109that it matches only unknown objects.
1110
11115. Updated the maintenance script maint/ManyConfigTests to make it easier to
1112select individual groups of tests.
1113
11146. When the POSIX wrapper function regcomp() is called, the REG_NOSUB option
1115used to set PCRE2_NO_AUTO_CAPTURE when calling pcre2_compile(). However, this
1116disables the use of back references (and subroutine calls), which are supported
1117by other implementations of regcomp() with RE_NOSUB. Therefore, REG_NOSUB no
1118longer causes PCRE2_NO_AUTO_CAPTURE to be set, though it still ignores nmatch
1119and pmatch when regexec() is called.
1120
11217. Because of 6 above, pcre2test has been modified with a new modifier called
1122posix_nosub, to call regcomp() with REG_NOSUB. Previously the no_auto_capture
1123modifier had this effect. That option is now ignored when the POSIX API is in
1124use.
1125
11268. Minor tidies to the pcre2demo.c sample program, including more comments
1127about its 8-bit-ness.
1128
11299. Detect unmatched closing parentheses and give the error in the pre-scan
1130instead of later. Previously the pre-scan carried on and could give a
1131misleading incorrect error message. For example, /(?J)(?'a'))(?'a')/ gave a
1132message about invalid duplicate group names.
1133
113410. It has happened that pcre2test was accidentally linked with another POSIX
1135regex library instead of libpcre2-posix. In this situation, a call to regcomp()
1136(in the other library) may succeed, returning zero, but of course putting its
1137own data into the regex_t block. In one example the re_pcre2_code field was
1138left as NULL, which made pcre2test think it had not got a compiled POSIX regex,
1139so it treated the next line as another pattern line, resulting in a confusing
1140error message. A check has been added to pcre2test to see if the data returned
1141from a successful call of regcomp() are valid for PCRE2's regcomp(). If they
1142are not, an error message is output and the pcre2test run is abandoned. The
1143message points out the possibility of a mis-linking. Hopefully this will avoid
1144some head-scratching the next time this happens.
1145
114611. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind
1147assertion, caused pcre2test to output a very large number of spaces when the
1148callout was taken, making the program appearing to loop.
1149
115012. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
1151nested set of parentheses of sufficient size caused an overflow of the
1152compiling workspace (which was diagnosed, but of course is not desirable).
1153
115413. Detect missing closing parentheses during the pre-pass for group
1155identification.
1156
115714. Changed some integer variable types and put in a number of casts, following
1158a report of compiler warnings from Visual Studio 2013 and a few tests with
1159gcc's -Wconversion (which still throws up a lot).
1160
116115. Implemented pcre2_code_copy(), and added pushcopy and #popcopy to pcre2test
1162for testing it.
1163
116416. Change 66 for 10.21 introduced the use of snprintf() in PCRE2's version of
1165regerror(). When the error buffer is too small, my version of snprintf() puts a
1166binary zero in the final byte. Bug #1801 seems to show that other versions do
1167not do this, leading to bad output from pcre2test when it was checking for
1168buffer overflow. It no longer assumes a binary zero at the end of a too-small
1169regerror() buffer.
1170
117117. Fixed typo ("&&" for "&") in pcre2_study(). Fortunately, this could not
1172actually affect anything, by sheer luck.
1173
117418. Two minor fixes for MSVC compilation: (a) removal of apparently incorrect
1175"const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for
1176older MSVC compilers. This has been done both in src/pcre2_internal.h for most
1177of the library, and also in src/pcre2posix.c, which no longer includes
1178pcre2_internal.h (see 24 below).
1179
118019. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
1181static compilation. Subsequently applied Chris Wilson's second patch, putting
1182the first patch under a new option instead of being unconditional when
1183PCRE_STATIC is set.
1184
118520. Updated pcre2grep to set stdout as binary when run under Windows, so as not
1186to convert \r\n at the ends of reflected lines into \r\r\n. This required
1187ensuring that other output that is written to stdout (e.g. file names) uses the
1188appropriate line terminator: \r\n for Windows, \n otherwise.
1189
119021. When a line is too long for pcre2grep's internal buffer, show the maximum
1191length in the error message.
1192
119322. Added support for string callouts to pcre2grep (Zoltan's patch with PH
1194additions).
1195
119623. RunTest.bat was missing a "set type" line for test 22.
1197
119824. The pcre2posix.c file was including pcre2_internal.h, and using some
1199"private" knowledge of the data structures. This is unnecessary; the code has
1200been re-factored and no longer includes pcre2_internal.h.
1201
120225. A racing condition is fixed in JIT reported by Mozilla.
1203
120426. Minor code refactor to avoid "array subscript is below array bounds"
1205compiler warning.
1206
120727. Minor code refactor to avoid "left shift of negative number" warning.
1208
120928. Add a bit more sanity checking to pcre2_serialize_decode() and document
1210that it expects trusted data.
1211
121229. Fix typo in pcre2_jit_test.c
1213
121430. Due to an oversight, pcre2grep was not making use of JIT when available.
1215This is now fixed.
1216
121731. The RunGrepTest script is updated to use the valgrind suppressions file
1218when testing with JIT under valgrind (compare 10.21/51 below). The suppressions
1219file is updated so that is now the same as for PCRE1: it suppresses the
1220Memcheck warnings Addr16 and Cond in unknown objects (that is, JIT-compiled
1221code). Also changed smc-check=all to smc-check=all-non-file as was done for
1222RunTest (see 4 above).
1223
122432. Implemented the PCRE2_NO_JIT option for pcre2_match().
1225
122633. Fix typo that gave a compiler error when JIT not supported.
1227
122834. Fix comment describing the returns from find_fixedlength().
1229
123035. Fix potential negative index in pcre2test.
1231
123236. Calls to pcre2_get_error_message() with error numbers that are never
1233returned by PCRE2 functions were returning empty strings. Now the error code
1234PCRE2_ERROR_BADDATA is returned. A facility has been added to pcre2test to
1235show the texts for given error numbers (i.e. to call pcre2_get_error_message()
1236and display what it returns) and a few representative error codes are now
1237checked in RunTest.
1238
123937. Added "&& !defined(__INTEL_COMPILER)" to the test for __GNUC__ in
1240pcre2_match.c, in anticipation that this is needed for the same reason it was
1241recently added to pcrecpp.cc in PCRE1.
1242
124338. Using -o with -M in pcre2grep could cause unnecessary repeated output when
1244the match extended over a line boundary, as it tried to find more matches "on
1245the same line" - but it was already over the end.
1246
124739. Allow \C in lookbehinds and DFA matching in UTF-32 mode (by converting it
1248to the same code as '.' when PCRE2_DOTALL is set).
1249
125040. Fix two clang compiler warnings in pcre2test when only one code unit width
1251is supported.
1252
Elliott Hughes653c2102019-01-09 15:41:36 -0800125341. Upgrade RunTest to automatically re-run test 2 with a large (64MiB) stack
1254if it fails when running the interpreter with a 16MiB stack (and if changing
1255the stack size via pcre2test is possible). This avoids having to manually set a
Janis Danisevskis8b979b22016-08-15 16:09:16 +01001256large stack size when testing with clang.
1257
125842. Fix register overwite in JIT when SSE2 acceleration is enabled.
1259
126043. Detect integer overflow in pcre2test pattern and data repetition counts.
1261
126244. In pcre2test, ignore "allcaptures" after DFA matching.
1263
126445. Fix unaligned accesses on x86. Patch by Marc Mutz.
1265
126646. Fix some more clang compiler warnings.
1267
1268
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001269Version 10.21 12-January-2016
1270-----------------------------
1271
12721. Improve matching speed of patterns starting with + or * in JIT.
1273
12742. Use memchr() to find the first character in an unanchored match in 8-bit
1275mode in the interpreter. This gives a significant speed improvement.
1276
12773. Removed a redundant copy of the opcode_possessify table in the
1278pcre2_auto_possessify.c source.
1279
12804. Fix typos in dftables.c for z/OS.
1281
12825. Change 36 for 10.20 broke the handling of [[:>:]] and [[:<:]] in that
1283processing them could involve a buffer overflow if the following character was
1284an opening parenthesis.
1285
12866. Change 36 for 10.20 also introduced a bug in processing this pattern:
1287/((?x)(*:0))#(?'/. Specifically: if a setting of (?x) was followed by a (*MARK)
1288setting (which (*:0) is), then (?x) did not get unset at the end of its group
1289during the scan for named groups, and hence the external # was incorrectly
1290treated as a comment and the invalid (?' at the end of the pattern was not
1291diagnosed. This caused a buffer overflow during the real compile. This bug was
1292discovered by Karl Skomski with the LLVM fuzzer.
1293
12947. Moved the pcre2_find_bracket() function from src/pcre2_compile.c into its
1295own source module to avoid a circular dependency between src/pcre2_compile.c
1296and src/pcre2_study.c
1297
12988. A callout with a string argument containing an opening square bracket, for
1299example /(?C$[$)(?<]/, was incorrectly processed and could provoke a buffer
1300overflow. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1301
13029. The handling of callouts during the pre-pass for named group identification
1303has been tightened up.
1304
130510. The quantifier {1} can be ignored, whether greedy, non-greedy, or
1306possessive. This is a very minor optimization.
1307
130811. A possessively repeated conditional group that could match an empty string,
1309for example, /(?(R))*+/, was incorrectly compiled.
1310
131112. The Unicode tables have been updated to Unicode 8.0.0 (thanks to Christian
1312Persch).
1313
131413. An empty comment (?#) in a pattern was incorrectly processed and could
1315provoke a buffer overflow. This bug was discovered by Karl Skomski with the
1316LLVM fuzzer.
1317
131814. Fix infinite recursion in the JIT compiler when certain patterns such as
1319/(?:|a|){100}x/ are analysed.
1320
132115. Some patterns with character classes involving [: and \\ were incorrectly
1322compiled and could cause reading from uninitialized memory or an incorrect
1323error diagnosis. Examples are: /[[:\\](?<[::]/ and /[[:\\](?'abc')[a:]. The
1324first of these bugs was discovered by Karl Skomski with the LLVM fuzzer.
1325
132616. Pathological patterns containing many nested occurrences of [: caused
1327pcre2_compile() to run for a very long time. This bug was found by the LLVM
1328fuzzer.
1329
133017. A missing closing parenthesis for a callout with a string argument was not
1331being diagnosed, possibly leading to a buffer overflow. This bug was found by
1332the LLVM fuzzer.
1333
133418. A conditional group with only one branch has an implicit empty alternative
1335branch and must therefore be treated as potentially matching an empty string.
1336
133719. If (?R was followed by - or + incorrect behaviour happened instead of a
1338diagnostic. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1339
134020. Another bug that was introduced by change 36 for 10.20: conditional groups
1341whose condition was an assertion preceded by an explicit callout with a string
1342argument might be incorrectly processed, especially if the string contained \Q.
1343This bug was discovered by Karl Skomski with the LLVM fuzzer.
1344
134521. Compiling PCRE2 with the sanitize options of clang showed up a number of
1346very pedantic coding infelicities and a buffer overflow while checking a UTF-8
1347string if the final multi-byte UTF-8 character was truncated.
1348
134922. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
1350class, where both values are literal letters in the same case, omit the
1351non-letter EBCDIC code points within the range.
1352
135323. Finding the minimum matching length of complex patterns with back
1354references and/or recursions can take a long time. There is now a cut-off that
1355gives up trying to find a minimum length when things get too complex.
1356
135724. An optimization has been added that speeds up finding the minimum matching
1358length for patterns containing repeated capturing groups or recursions.
1359
136025. If a pattern contained a back reference to a group whose number was
1361duplicated as a result of appearing in a (?|...) group, the computation of the
1362minimum matching length gave a wrong result, which could cause incorrect "no
1363match" errors. For such patterns, a minimum matching length cannot at present
1364be computed.
1365
136626. Added a check for integer overflow in conditions (?(<digits>) and
1367(?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
1368fuzzer.
1369
137027. Fixed an issue when \p{Any} inside an xclass did not read the current
1371character.
1372
137328. If pcre2grep was given the -q option with -c or -l, or when handling a
1374binary file, it incorrectly wrote output to stdout.
1375
137629. The JIT compiler did not restore the control verb head in case of *THEN
1377control verbs. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1378
137930. The way recursive references such as (?3) are compiled has been re-written
1380because the old way was the cause of many issues. Now, conversion of the group
1381number into a pattern offset does not happen until the pattern has been
1382completely compiled. This does mean that detection of all infinitely looping
1383recursions is postponed till match time. In the past, some easy ones were
1384detected at compile time. This re-writing was done in response to yet another
1385bug found by the LLVM fuzzer.
1386
138731. A test for a back reference to a non-existent group was missing for items
1388such as \987. This caused incorrect code to be compiled. This issue was found
1389by Karl Skomski with a custom LLVM fuzzer.
1390
139132. Error messages for syntax errors following \g and \k were giving inaccurate
1392offsets in the pattern.
1393
139433. Improve the performance of starting single character repetitions in JIT.
1395
139634. (*LIMIT_MATCH=) now gives an error instead of setting the value to 0.
1397
139835. Error messages for syntax errors in *LIMIT_MATCH and *LIMIT_RECURSION now
1399give the right offset instead of zero.
1400
140136. The JIT compiler should not check repeats after a {0,1} repeat byte code.
1402This issue was found by Karl Skomski with a custom LLVM fuzzer.
1403
140437. The JIT compiler should restore the control chain for empty possessive
1405repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1406
140738. A bug which was introduced by the single character repetition optimization
1408was fixed.
1409
141039. Match limit check added to recursion. This issue was found by Karl Skomski
1411with a custom LLVM fuzzer.
1412
141340. Arrange for the UTF check in pcre2_match() and pcre2_dfa_match() to look
1414only at the part of the subject that is relevant when the starting offset is
1415non-zero.
1416
141741. Improve first character match in JIT with SSE2 on x86.
1418
141942. Fix two assertion fails in JIT. These issues were found by Karl Skomski
1420with a custom LLVM fuzzer.
1421
142243. Correct the setting of CMAKE_C_FLAGS in CMakeLists.txt (patch from Roy Ivy
1423III).
1424
142544. Fix bug in RunTest.bat for new test 14, and adjust the script for the added
1426test (there are now 20 in total).
1427
142845. Fixed a corner case of range optimization in JIT.
1429
143046. Add the ${*MARK} facility to pcre2_substitute().
1431
143247. Modifier lists in pcre2test were splitting at spaces without the required
1433commas.
1434
143548. Implemented PCRE2_ALT_VERBNAMES.
1436
143749. Fixed two issues in JIT. These were found by Karl Skomski with a custom
1438LLVM fuzzer.
1439
144050. The pcre2test program has been extended by adding the #newline_default
1441command. This has made it possible to run the standard tests when PCRE2 is
1442compiled with either CR or CRLF as the default newline convention. As part of
1443this work, the new command was added to several test files and the testing
1444scripts were modified. The pcre2grep tests can now also be run when there is no
1445LF in the default newline convention.
1446
144751. The RunTest script has been modified so that, when JIT is used and valgrind
1448is specified, a valgrind suppressions file is set up to ignore "Invalid read of
1449size 16" errors because these are false positives when the hardware supports
1450the SSE2 instruction set.
1451
145252. It is now possible to have comment lines amid the subject strings in
1453pcre2test (and perltest.sh) input.
1454
145553. Implemented PCRE2_USE_OFFSET_LIMIT and pcre2_set_offset_limit().
1456
145754. Add the null_context modifier to pcre2test so that calling pcre2_compile()
1458and the matching functions with NULL contexts can be tested.
1459
146055. Implemented PCRE2_SUBSTITUTE_EXTENDED.
1461
146256. In a character class such as [\W\p{Any}] where both a negative-type escape
1463("not a word character") and a property escape were present, the property
1464escape was being ignored.
1465
146657. Fixed integer overflow for patterns whose minimum matching length is very,
1467very large.
1468
146958. Implemented --never-backslash-C.
1470
147159. Change 55 above introduced a bug by which certain patterns provoked the
1472erroneous error "\ at end of pattern".
1473
147460. The special sequences [[:<:]] and [[:>:]] gave rise to incorrect compiling
1475errors or other strange effects if compiled in UCP mode. Found with libFuzzer
1476and AddressSanitizer.
1477
147861. Whitespace at the end of a pcre2test pattern line caused a spurious error
1479message if there were only single-character modifiers. It should be ignored.
1480
148162. The use of PCRE2_NO_AUTO_CAPTURE could cause incorrect compilation results
1482or segmentation errors for some patterns. Found with libFuzzer and
1483AddressSanitizer.
1484
148563. Very long names in (*MARK) or (*THEN) etc. items could provoke a buffer
1486overflow.
1487
148864. Improve error message for overly-complicated patterns.
1489
149065. Implemented an optional replication feature for patterns in pcre2test, to
1491make it easier to test long repetitive patterns. The tests for 63 above are
1492converted to use the new feature.
1493
149466. In the POSIX wrapper, if regerror() was given too small a buffer, it could
1495misbehave.
1496
149767. In pcre2_substitute() in UTF mode, the UTF validity check on the
1498replacement string was happening before the length setting when the replacement
1499string was zero-terminated.
1500
150168. In pcre2_substitute() in UTF mode, PCRE2_NO_UTF_CHECK can be set for the
1502second and subsequent calls to pcre2_match().
1503
150469. There was no check for integer overflow for a replacement group number in
1505pcre2_substitute(). An added check for a number greater than the largest group
1506number in the pattern means this is not now needed.
1507
150870. The PCRE2-specific VERSION condition didn't work correctly if only one
1509digit was given after the decimal point, or if more than two digits were given.
1510It now works with one or two digits, and gives a compile time error if more are
1511given.
1512
151371. In pcre2_substitute() there was the possibility of reading one code unit
1514beyond the end of the replacement string.
1515
151672. The code for checking a subject's UTF-32 validity for a pattern with a
1517lookbehind involved an out-of-bounds pointer, which could potentially cause
1518trouble in some environments.
1519
152073. The maximum lookbehind length was incorrectly calculated for patterns such
1521as /(?<=(a)(?-1))x/ which have a recursion within a backreference.
1522
152374. Give an error if a lookbehind assertion is longer than 65535 code units.
1524
152575. Give an error in pcre2_substitute() if a match ends before it starts (as a
1526result of the use of \K).
1527
152876. Check the length of subpattern names and the names in (*MARK:xx) etc.
1529dynamically to avoid the possibility of integer overflow.
1530
153177. Implement pcre2_set_max_pattern_length() so that programs can restrict the
1532size of patterns that they are prepared to handle.
1533
153478. (*NO_AUTO_POSSESS) was not working.
1535
153679. Adding group information caching improves the speed of compiling when
1537checking whether a group has a fixed length and/or could match an empty string,
1538especially when recursion or subroutine calls are involved. However, this
1539cannot be used when (?| is present in the pattern because the same number may
1540be used for groups of different sizes. To catch runaway patterns in this
1541situation, counts have been introduced to the functions that scan for empty
1542branches or compute fixed lengths.
1543
154480. Allow for the possibility of the size of the nest_save structure not being
1545a factor of the size of the compiling workspace (it currently is).
1546
154781. Check for integer overflow in minimum length calculation and cap it at
154865535.
1549
155082. Small optimizations in code for finding the minimum matching length.
1551
155283. Lock out configuring for EBCDIC with non-8-bit libraries.
1553
155484. Test for error code <= 0 in regerror().
1555
155685. Check for too many replacements (more than INT_MAX) in pcre2_substitute().
1557
155886. Avoid the possibility of computing with an out-of-bounds pointer (though
1559not dereferencing it) while handling lookbehind assertions.
1560
156187. Failure to get memory for the match data in regcomp() is now given as a
1562regcomp() error instead of waiting for regexec() to pick it up.
1563
156488. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
1565newline sequence.
1566
156789. Paranoid check in regcomp() for bad error code from pcre2_compile().
1568
156990. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
1570as for link size 2.
1571
157291. Document that JIT has a limit on pattern size, and give more information
1573about JIT compile failures in pcre2test.
1574
157592. Implement PCRE2_INFO_HASBACKSLASHC.
1576
157793. Re-arrange valgrind support code in pcre2test to avoid spurious reports
1578with JIT (possibly caused by SSE2?).
1579
158094. Support offset_limit in JIT.
1581
158295. A sequence such as [[:punct:]b] that is, a POSIX character class followed
1583by a single ASCII character in a class item, was incorrectly compiled in UCP
1584mode. The POSIX class got lost, but only if the single character followed it.
1585
158696. [:punct:] in UCP mode was matching some characters in the range 128-255
1587that should not have been matched.
1588
158997. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
1590characters with code points greater than 255 are in the class. When a Unicode
1591property was also in the class (if PCRE2_UCP is set, escapes such as \w are
1592turned into Unicode properties), wide characters were not correctly handled,
1593and could fail to match.
1594
159598. In pcre2test, make the "startoffset" modifier a synonym of "offset",
1596because it sets the "startoffset" parameter for pcre2_match().
1597
159899. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
1599an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
1600misbehaved. This bug was found by the LLVM fuzzer.
1601
1602100. The error for an invalid UTF pattern string always gave the code unit
1603offset as zero instead of where the invalidity was found.
1604
1605101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
1606working correctly in UCP mode.
1607
1608102. Similar to 99 above, if an isolated \E was present between an item and its
1609qualifier when PCRE2_AUTO_CALLOUT was set, pcre2_compile() misbehaved. This bug
1610was found by the LLVM fuzzer.
1611
1612103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
1613was set when the pmatch argument was NULL. It now returns REG_INVARG.
1614
1615104. Allow for up to 32-bit numbers in the ordin() function in pcre2grep.
1616
1617105. An empty \Q\E sequence between an item and its qualifier caused
1618pcre2_compile() to misbehave when auto callouts were enabled. This bug
1619was found by the LLVM fuzzer.
1620
1621106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
1622other verb "name" ended with whitespace immediately before the closing
1623parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
1624both those options were set.
1625
1626107. In a number of places pcre2_compile() was not handling NULL characters
1627correctly, and pcre2test with the "bincode" modifier was not always correctly
1628displaying fields containing NULLS:
1629
1630 (a) Within /x extended #-comments
1631 (b) Within the "name" part of (*MARK) and other *verbs
1632 (c) Within the text argument of a callout
1633
1634108. If a pattern that was compiled with PCRE2_EXTENDED started with white
1635space or a #-type comment that was followed by (?-x), which turns off
1636PCRE2_EXTENDED, and there was no subsequent (?x) to turn it on again,
1637pcre2_compile() assumed that (?-x) applied to the whole pattern and
1638consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix
Janis Danisevskis8b979b22016-08-15 16:09:16 +01001639for this bug means that a setting of any of the (?imsxJU) options at the start
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001640of a pattern is no longer transferred to the options that are returned by
1641PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have
1642changed when the effects of those options were all moved to compile time.
1643
1644109. An escaped closing parenthesis in the "name" part of a (*verb) when
1645PCRE2_ALT_VERBNAMES was set caused pcre2_compile() to malfunction. This bug
1646was found by the LLVM fuzzer.
1647
1648110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
1649possible to test it.
1650
1651111. "Harden" pcre2test against ridiculously large values in modifiers and
1652command line arguments.
1653
1654112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_
1655LENGTH.
1656
1657113. Fix printing of *MARK names that contain binary zeroes in pcre2test.
1658
1659
1660Version 10.20 30-June-2015
1661--------------------------
1662
16631. Callouts with string arguments have been added.
1664
16652. Assertion code generator in JIT has been optimized.
1666
16673. The invalid pattern (?(?C) has a missing assertion condition at the end. The
1668pcre2_compile() function read past the end of the input before diagnosing an
1669error. This bug was discovered by the LLVM fuzzer.
1670
16714. Implemented pcre2_callout_enumerate().
1672
16735. Fix JIT compilation of conditional blocks whose assertion is converted to
1674(*FAIL). E.g: /(?(?!))/.
1675
16766. The pattern /(?(?!)^)/ caused references to random memory. This bug was
1677discovered by the LLVM fuzzer.
1678
16797. The assertion (?!) is optimized to (*FAIL). This was not handled correctly
1680when this assertion was used as a condition, for example (?(?!)a|b). In
1681pcre2_match() it worked by luck; in pcre2_dfa_match() it gave an incorrect
1682error about an unsupported item.
1683
16848. For some types of pattern, for example /Z*(|d*){216}/, the auto-
1685possessification code could take exponential time to complete. A recursion
1686depth limit of 1000 has been imposed to limit the resources used by this
1687optimization. This infelicity was discovered by the LLVM fuzzer.
1688
16899. A pattern such as /(*UTF)[\S\V\H]/, which contains a negated special class
1690such as \S in non-UCP mode, explicit wide characters (> 255) can be ignored
1691because \S ensures they are all in the class. The code for doing this was
1692interacting badly with the code for computing the amount of space needed to
1693compile the pattern, leading to a buffer overflow. This bug was discovered by
1694the LLVM fuzzer.
1695
169610. A pattern such as /((?2)+)((?1))/ which has mutual recursion nested inside
1697other kinds of group caused stack overflow at compile time. This bug was
1698discovered by the LLVM fuzzer.
1699
170011. A pattern such as /(?1)(?#?'){8}(a)/ which had a parenthesized comment
1701between a subroutine call and its quantifier was incorrectly compiled, leading
1702to buffer overflow or other errors. This bug was discovered by the LLVM fuzzer.
1703
170412. The illegal pattern /(?(?<E>.*!.*)?)/ was not being diagnosed as missing an
1705assertion after (?(. The code was failing to check the character after (?(?<
1706for the ! or = that would indicate a lookbehind assertion. This bug was
1707discovered by the LLVM fuzzer.
1708
170913. A pattern such as /X((?2)()*+){2}+/ which has a possessive quantifier with
1710a fixed maximum following a group that contains a subroutine reference was
1711incorrectly compiled and could trigger buffer overflow. This bug was discovered
1712by the LLVM fuzzer.
1713
171414. Negative relative recursive references such as (?-7) to non-existent
1715subpatterns were not being diagnosed and could lead to unpredictable behaviour.
1716This bug was discovered by the LLVM fuzzer.
1717
171815. The bug fixed in 14 was due to an integer variable that was unsigned when
1719it should have been signed. Some other "int" variables, having been checked,
1720have either been changed to uint32_t or commented as "must be signed".
1721
172216. A mutual recursion within a lookbehind assertion such as (?<=((?2))((?1)))
1723caused a stack overflow instead of the diagnosis of a non-fixed length
1724lookbehind assertion. This bug was discovered by the LLVM fuzzer.
1725
172617. The use of \K in a positive lookbehind assertion in a non-anchored pattern
1727(e.g. /(?<=\Ka)/) could make pcre2grep loop.
1728
172918. There was a similar problem to 17 in pcre2test for global matches, though
1730the code there did catch the loop.
1731
173219. If a greedy quantified \X was preceded by \C in UTF mode (e.g. \C\X*),
1733and a subsequent item in the pattern caused a non-match, backtracking over the
1734repeated \X did not stop, but carried on past the start of the subject, causing
1735reference to random memory and/or a segfault. There were also some other cases
1736where backtracking after \C could crash. This set of bugs was discovered by the
1737LLVM fuzzer.
1738
173920. The function for finding the minimum length of a matching string could take
1740a very long time if mutual recursion was present many times in a pattern, for
1741example, /((?2){73}(?2))((?1))/. A better mutual recursion detection method has
1742been implemented. This infelicity was discovered by the LLVM fuzzer.
1743
174421. Implemented PCRE2_NEVER_BACKSLASH_C.
1745
174622. The feature for string replication in pcre2test could read from freed
1747memory if the replication required a buffer to be extended, and it was not
1748working properly in 16-bit and 32-bit modes. This issue was discovered by a
1749fuzzer: see http://lcamtuf.coredump.cx/afl/.
1750
175123. Added the PCRE2_ALT_CIRCUMFLEX option.
1752
175324. Adjust the treatment of \8 and \9 to be the same as the current Perl
1754behaviour.
1755
175625. Static linking against the PCRE2 library using the pkg-config module was
1757failing on missing pthread symbols.
1758
175926. If a group that contained a recursive back reference also contained a
1760forward reference subroutine call followed by a non-forward-reference
1761subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
1762compile correct code, leading to undefined behaviour or an internally detected
1763error. This bug was discovered by the LLVM fuzzer.
1764
176527. Quantification of certain items (e.g. atomic back references) could cause
1766incorrect code to be compiled when recursive forward references were involved.
1767For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/. This bug was
1768discovered by the LLVM fuzzer.
1769
177028. A repeated conditional group whose condition was a reference by name caused
1771a buffer overflow if there was more than one group with the given name. This
1772bug was discovered by the LLVM fuzzer.
1773
177429. A recursive back reference by name within a group that had the same name as
1775another group caused a buffer overflow. For example: /(?J)(?'d'(?'d'\g{d}))/.
1776This bug was discovered by the LLVM fuzzer.
1777
177830. A forward reference by name to a group whose number is the same as the
1779current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused a
1780buffer overflow at compile time. This bug was discovered by the LLVM fuzzer.
1781
178231. Fix -fsanitize=undefined warnings for left shifts of 1 by 31 (it treats 1
1783as an int; fixed by writing it as 1u).
1784
178532. Fix pcre2grep compile when -std=c99 is used with gcc, though it still gives
1786a warning for "fileno" unless -std=gnu99 us used.
1787
178833. A lookbehind assertion within a set of mutually recursive subpatterns could
1789provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
1790
179134. Give an error for an empty subpattern name such as (?'').
1792
179335. Make pcre2test give an error if a pattern that follows #forbud_utf contains
1794\P, \p, or \X.
1795
179636. The way named subpatterns are handled has been refactored. There is now a
1797pre-pass over the regex which does nothing other than identify named
1798subpatterns and count the total captures. This means that information about
1799named patterns is known before the rest of the compile. In particular, it means
1800that forward references can be checked as they are encountered. Previously, the
1801code for handling forward references was contorted and led to several errors in
1802computing the memory requirements for some patterns, leading to buffer
1803overflows.
1804
180537. There was no check for integer overflow in subroutine calls such as (?123).
1806
180738. The table entry for \l in EBCDIC environments was incorrect, leading to its
1808being treated as a literal 'l' instead of causing an error.
1809
181039. If a non-capturing group containing a conditional group that could match
1811an empty string was repeated, it was not identified as matching an empty string
1812itself. For example: /^(?:(?(1)x|)+)+$()/.
1813
181440. In an EBCDIC environment, pcretest was mishandling the escape sequences
1815\a and \e in test subject lines.
1816
181741. In an EBCDIC environment, \a in a pattern was converted to the ASCII
1818instead of the EBCDIC value.
1819
182042. The handling of \c in an EBCDIC environment has been revised so that it is
1821now compatible with the specification in Perl's perlebcdic page.
1822
182343. Single character repetition in JIT has been improved. 20-30% speedup
1824was achieved on certain patterns.
1825
182644. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
1827ASCII/Unicode. This has now been added to the list of characters that are
1828recognized as white space in EBCDIC.
1829
183045. When PCRE2 was compiled without Unicode support, the use of \p and \P gave
1831an error (correctly) when used outside a class, but did not give an error
1832within a class.
1833
183446. \h within a class was incorrectly compiled in EBCDIC environments.
1835
183647. JIT should return with error when the compiled pattern requires
1837more stack space than the maximum.
1838
183948. Fixed a memory leak in pcre2grep when a locale is set.
1840
1841
1842Version 10.10 06-March-2015
1843---------------------------
1844
18451. When a pattern is compiled, it remembers the highest back reference so that
1846when matching, if the ovector is too small, extra memory can be obtained to
1847use instead. A conditional subpattern whose condition is a check on a capture
1848having happened, such as, for example in the pattern /^(?:(a)|b)(?(1)A|B)/, is
1849another kind of back reference, but it was not setting the highest
1850backreference number. This mattered only if pcre2_match() was called with an
1851ovector that was too small to hold the capture, and there was no other kind of
1852back reference (a situation which is probably quite rare). The effect of the
1853bug was that the condition was always treated as FALSE when the capture could
1854not be consulted, leading to a incorrect behaviour by pcre2_match(). This bug
1855has been fixed.
1856
18572. Functions for serialization and deserialization of sets of compiled patterns
1858have been added.
1859
18603. The value that is returned by PCRE2_INFO_SIZE has been corrected to remove
1861excess code units at the end of the data block that may occasionally occur if
1862the code for calculating the size over-estimates. This change stops the
1863serialization code copying uninitialized data, to which valgrind objects. The
1864documentation of PCRE2_INFO_SIZE was incorrect in stating that the size did not
1865include the general overhead. This has been corrected.
1866
18674. All code units in every slot in the table of group names are now set, again
1868in order to avoid accessing uninitialized data when serializing.
1869
18705. The (*NO_JIT) feature is implemented.
1871
18726. If a bug that caused pcre2_compile() to use more memory than allocated was
1873triggered when using valgrind, the code in (3) above passed a stupidly large
1874value to valgrind. This caused a crash instead of an "internal error" return.
1875
18767. A reference to a duplicated named group (either a back reference or a test
1877for being set in a conditional) that occurred in a part of the pattern where
1878PCRE2_DUPNAMES was not set caused the amount of memory needed for the pattern
1879to be incorrectly calculated, leading to overwriting.
1880
18818. A mutually recursive set of back references such as (\2)(\1) caused a
1882segfault at compile time (while trying to find the minimum matching length).
1883The infinite loop is now broken (with the minimum length unset, that is, zero).
1884
18859. If an assertion that was used as a condition was quantified with a minimum
1886of zero, matching went wrong. In particular, if the whole group had unlimited
1887repetition and could match an empty string, a segfault was likely. The pattern
1888(?(?=0)?)+ is an example that caused this. Perl allows assertions to be
1889quantified, but not if they are being used as conditions, so the above pattern
1890is faulted by Perl. PCRE2 has now been changed so that it also rejects such
1891patterns.
1892
189310. The error message for an invalid quantifier has been changed from "nothing
1894to repeat" to "quantifier does not follow a repeatable item".
1895
189611. If a bad UTF string is compiled with NO_UTF_CHECK, it may succeed, but
1897scanning the compiled pattern in subsequent auto-possessification can get out
1898of step and lead to an unknown opcode. Previously this could have caused an
1899infinite loop. Now it generates an "internal error" error. This is a tidyup,
1900not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an
1901undefined outcome.
1902
190312. A UTF pattern containing a "not" match of a non-ASCII character and a
1904subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.
1905
190613. The locale test (RunTest 3) has been upgraded. It now checks that a locale
1907that is found in the output of "locale -a" can actually be set by pcre2test
1908before it is accepted. Previously, in an environment where a locale was listed
1909but would not set (an example does exist), the test would "pass" without
1910actually doing anything. Also the fr_CA locale has been added to the list of
1911locales that can be used.
1912
191314. Fixed a bug in pcre2_substitute(). If a replacement string ended in a
1914capturing group number without parentheses, the last character was incorrectly
1915literally included at the end of the replacement string.
1916
191715. A possessive capturing group such as (a)*+ with a minimum repeat of zero
1918failed to allow the zero-repeat case if pcre2_match() was called with an
1919ovector too small to capture the group.
1920
192116. Improved error message in pcre2test when setting the stack size (-S) fails.
1922
192317. Fixed two bugs in CMakeLists.txt: (1) Some lines had got lost in the
1924transfer from PCRE1, meaning that CMake configuration failed if "build tests"
1925was selected. (2) The file src/pcre2_serialize.c had not been added to the list
1926of PCRE2 sources, which caused a failure to build pcre2test.
1927
192818. Fixed typo in pcre2_serialize.c (DECL instead of DEFN) that causes problems
1929only on Windows.
1930
193119. Use binary input when reading back saved serialized patterns in pcre2test.
1932
193320. Added RunTest.bat for running the tests under Windows.
1934
193521. "make distclean" was not removing config.h, a file that may be created for
1936use with CMake.
1937
193822. A pattern such as "((?2){0,1999}())?", which has a group containing a
1939forward reference repeated a large (but limited) number of times within a
1940repeated outer group that has a zero minimum quantifier, caused incorrect code
1941to be compiled, leading to the error "internal error: previously-checked
1942referenced subpattern not found" when an incorrect memory address was read.
1943This bug was reported as "heap overflow", discovered by Kai Lu of Fortinet's
1944FortiGuard Labs. (Added 24-March-2015: CVE-2015-2325 was given to this.)
1945
194623. A pattern such as "((?+1)(\1))/" containing a forward reference subroutine
1947call within a group that also contained a recursive back reference caused
1948incorrect code to be compiled. This bug was reported as "heap overflow",
1949discovered by Kai Lu of Fortinet's FortiGuard Labs. (Added 24-March-2015:
1950CVE-2015-2326 was given to this.)
1951
195224. Computing the size of the JIT read-only data in advance has been a source
1953of various issues, and new ones are still appear unfortunately. To fix
1954existing and future issues, size computation is eliminated from the code,
1955and replaced by on-demand memory allocation.
1956
195725. A pattern such as /(?i)[A-`]/, where characters in the other case are
1958adjacent to the end of the range, and the range contained characters with more
1959than one other case, caused incorrect behaviour when compiled in UTF mode. In
1960that example, the range a-j was left out of the class.
1961
1962
1963Version 10.00 05-January-2015
1964-----------------------------
1965
1966Version 10.00 is the first release of PCRE2, a revised API for the PCRE
1967library. Changes prior to 10.00 are logged in the ChangeLog file for the old
1968API, up to item 20 for release 8.36.
1969
1970The code of the library was heavily revised as part of the new API
1971implementation. Details of each and every modification were not individually
1972logged. In addition to the API changes, the following changes were made. They
1973are either new functionality, or bug fixes and other noticeable changes of
1974behaviour that were implemented after the code had been forked.
1975
19761. Including Unicode support at build time is now enabled by default, but it
1977can optionally be disabled. It is not enabled by default at run time (no
1978change).
1979
19802. The test program, now called pcre2test, was re-specified and almost
1981completely re-written. Its input is not compatible with input for pcretest.
1982
19833. Patterns may start with (*NOTEMPTY) or (*NOTEMPTY_ATSTART) to set the
1984PCRE2_NOTEMPTY or PCRE2_NOTEMPTY_ATSTART options for every subject line that is
1985matched by that pattern.
1986
19874. For the benefit of those who use PCRE2 via some other application, that is,
1988not writing the function calls themselves, it is possible to check the PCRE2
1989version by matching a pattern such as /(?(VERSION>=10)yes|no)/ against a
1990string such as "yesno".
1991
19925. There are case-equivalent Unicode characters whose encodings use different
1993numbers of code units in UTF-8. U+023A and U+2C65 are one example. (It is
1994theoretically possible for this to happen in UTF-16 too.) If a backreference to
1995a group containing one of these characters was greedily repeated, and during
1996the match a backtrack occurred, the subject might be backtracked by the wrong
1997number of code units. For example, if /^(\x{23a})\1*(.)/ is matched caselessly
1998(and in UTF-8 mode) against "\x{23a}\x{2c65}\x{2c65}\x{2c65}", group 2 should
1999capture the final character, which is the three bytes E2, B1, and A5 in UTF-8.
2000Incorrect backtracking meant that group 2 captured only the last two bytes.
2001This bug has been fixed; the new code is slower, but it is used only when the
2002strings matched by the repetition are not all the same length.
2003
20046. A pattern such as /()a/ was not setting the "first character must be 'a'"
2005information. This applied to any pattern with a group that matched no
2006characters, for example: /(?:(?=.)|(?<!x))a/.
2007
20087. When an (*ACCEPT) is triggered inside capturing parentheses, it arranges for
2009those parentheses to be closed with whatever has been captured so far. However,
2010it was failing to mark any other groups between the highest capture so far and
2011the currrent group as "unset". Thus, the ovector for those groups contained
2012whatever was previously there. An example is the pattern /(x)|((*ACCEPT))/ when
2013matched against "abcd".
2014
20158. The pcre2_substitute() function has been implemented.
2016
20179. If an assertion used as a condition was quantified with a minimum of zero
2018(an odd thing to do, but it happened), SIGSEGV or other misbehaviour could
2019occur.
2020
202110. The PCRE2_NO_DOTSTAR_ANCHOR option has been implemented.
2022
2023****