blob: 06b69f8dc878f0dd470378d11067207115733995 [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 Hughes653c2102019-01-09 15:41:36 -08005Version 10.32-RC1 10-September-2018
6-----------------------------------
7
81. When matching using the the REG_STARTEND feature of the POSIX API with a
9non-zero starting offset, unset capturing groups with lower numbers than a
10group that did capture something were not being correctly returned as "unset"
11(that is, with offset values of -1).
12
132. When matching using the POSIX API, pcre2test used to omit listing unset
14groups altogether. Now it shows those that come before any actual captures as
15"<unset>", as happens for non-POSIX matching.
16
173. Running "pcre2test -C" always stated "\R matches CR, LF, or CRLF only",
18whatever the build configuration was. It now correctly says "\R matches all
19Unicode newlines" in the default case when --enable-bsr-anycrlf has not been
20specified. Similarly, running "pcre2test -C bsr" never produced the result
21ANY.
22
234. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string containing
24multi-code-unit characters caused bad behaviour and possibly a crash. This
25issue was fixed for other kinds of repeat in release 10.20 by change 19, but
26repeating character classes were overlooked.
27
285. pcre2grep now supports the inclusion of binary zeros in patterns that are
29read from files via the -f option.
30
316. A small fix to pcre2grep to avoid compiler warnings for -Wformat-overflow=2.
32
337. Added --enable-jit=auto support to configure.ac.
34
358. Added some dummy variables to the heapframe structure in 16-bit and 32-bit
36modes for the benefit of m68k, where pointers can be 16-bit aligned. The
37dummies force 32-bit alignment and this ensures that the structure is a
38multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
39architectures, alignment requirements take care of this automatically.
40
419. When returning an error from pcre2_pattern_convert(), ensure the error
42offset is set zero for early errors.
43
4410. A number of patches for Windows support from Daniel Richard G:
45
46 (a) List of error numbers in Runtest.bat corrected (it was not the same as in
47 Runtest).
48
49 (b) pcre2grep snprintf() workaround as used elsewhere in the tree.
50
51 (c) Support for non-C99 snprintf() that returns -1 in the overflow case.
52
5311. Minor tidy of pcre2_dfa_match() code.
54
5512. Refactored pcre2_dfa_match() so that the internal recursive calls no longer
56use the stack for local workspace and local ovectors. Instead, an initial block
57of stack is reserved, but if this is insufficient, heap memory is used. The
58heap limit parameter now applies to pcre2_dfa_match().
59
6013. If a "find limits" test of DFA matching in pcre2test resulted in too many
61matches for the ovector, no matches were displayed.
62
6314. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as
64EOF. The test looks to have come from a fuzzer.
65
6615. If PCRE2 was built with a default match limit a lot greater than the
67default default of 10 000 000, some JIT tests of the match limit no longer
68failed. All such tests now set 10 000 000 as the upper limit.
69
7016. Another Windows related patch for pcregrep to ensure that WIN32 is
71undefined under Cygwin.
72
7317. Test for the presence of stdint.h and inttypes.h in configure and CMake and
74include whichever exists (stdint preferred) instead of unconditionally
75including stdint. This makes life easier for old and non-standard systems.
76
7718. Further changes to improve portability, especially to old and or non-
78standard systems:
79
80 (a) Put all printf arguments in RunGrepTest into single, not double, quotes,
81 and use \0 not \x00 for binary zero.
82
83 (b) Avoid the use of C++ (i.e. BCPL) // comments.
84
85 (c) Parameterize the use of %zu in pcre2test to make it like %td. For both of
86 these now, if using MSVC or a standard C before C99, %lu is used with a
87 cast if necessary.
88
8919. Applied a contributed patch to CMakeLists.txt to increase the stack size
90when linking pcre2test with MSVC. This gets rid of a stack overflow error in
91the standard set of tests.
92
9320. Output a warning in pcre2test when ignoring the "altglobal" modifier when
94it is given with the "replace" modifier.
95
9621. In both pcre2test and pcre2_substitute(), with global matching, a pattern
97that matched an empty string, but never at the starting match offset, was not
98handled in a Perl-compatible way. The pattern /(<?=\G.)/ is an example of such
99a pattern. Because \G is in a lookbehind assertion, there has to be a
100"bumpalong" before there can be a match. The automatic "advance by one
101character after an empty string match" rule is therefore inappropriate. A more
102complicated algorithm has now been implemented.
103
10422. When checking to see if a lookbehind is of fixed length, lookaheads were
105correctly ignored, but qualifiers on lookaheads were not being ignored, leading
106to an incorrect "lookbehind assertion is not fixed length" error.
107
10823. The VERSION condition test was reading fractional PCRE2 version numbers
109such as the 04 in 10.04 incorrectly and hence giving wrong results.
110
11124. Updated to Unicode version 11.0.0. As well as the usual addition of new
112scripts and characters, this involved re-jigging the grapheme break property
113algorithm because Unicode has changed the way emojis are handled.
114
11525. Fixed an obscure bug that struck when there were two atomic groups not
116separated by something with a backtracking point. There could be an incorrect
117backtrack into the first of the atomic groups. A complicated example is
118/(?>a(*:1))(?>b)(*SKIP:1)x|.*/ matched against "abc", where the *SKIP
119shouldn't find a MARK (because is in an atomic group), but it did.
120
12126. Upgraded the perltest.sh script: (1) #pattern lines can now be used to set
122a list of modifiers for all subsequent patterns - only those that the script
123recognizes are meaningful; (2) #subject lines can be used to set or unset a
124default "mark" modifier; (3) Unsupported #command lines give a warning when
125they are ignored; (4) Mark data is output only if the "mark" modifier is
126present.
127
12827. (*ACCEPT:ARG), (*FAIL:ARG), and (*COMMIT:ARG) are now supported.
129
13028. A (*MARK) name was not being passed back for positive assertions that were
131terminated by (*ACCEPT).
132
13329. Add support for \N{U+dddd}, but only in Unicode mode.
134
13530. Add support for (?^) for unsetting all imnsx options.
136
13731. The PCRE2_EXTENDED (/x) option only ever discarded space characters whose
138code point was less than 256 and that were recognized by the lookup table
139generated by pcre2_maketables(), which uses isspace() to identify white space.
140Now, when Unicode support is compiled, PCRE2_EXTENDED also discards U+0085,
141U+200E, U+200F, U+2028, and U+2029, which are additional characters defined by
142Unicode as "Pattern White Space". This makes PCRE2 compatible with Perl.
143
14432. In certain circumstances, option settings within patterns were not being
145correctly processed. For example, the pattern /((?i)A)(?m)B/ incorrectly
146matched "ab". (The (?m) setting lost the fact that (?i) should be reset at the
147end of its group during the parse process, but without another setting such as
148(?m) the compile phase got it right.) This bug was introduced by the
149refactoring in release 10.23.
150
15133. PCRE2 uses bcopy() if available when memmove() is not, and it used just to
152define memmove() as function call to bcopy(). This hasn't been tested for a
153long time because in pcre2test the result of memmove() was being used, whereas
154bcopy() doesn't return a result. This feature is now refactored always to call
155an emulation function when there is no memmove(). The emulation makes use of
156bcopy() when available.
157
15834. When serializing a pattern, set the memctl, executable_jit, and tables
159fields (that is, all the fields that contain pointers) to zeros so that the
160result of serializing is always the same. These fields are re-set when the
161pattern is deserialized.
162
16335. In a pattern such as /[^\x{100}-\x{ffff}]*[\x80-\xff]/ which has a repeated
164negative class with no characters less than 0x100 followed by a positive class
165with only characters less than 0x100, the first class was incorrectly being
166auto-possessified, causing incorrect match failures.
167
16836. Removed the character type bit ctype_meta, which dates from PCRE1 and is
169not used in PCRE2.
170
17137. Tidied up unnecessarily complicated macros used in the escapes table.
172
17338. Since 10.21, the new testoutput8-16-4 file has accidentally been omitted
174from distribution tarballs, owing to a typo in Makefile.am which had
175testoutput8-16-3 twice. Now fixed.
176
17739. If the only branch in a conditional subpattern was anchored, the whole
178subpattern was treated as anchored, when it should not have been, since the
179assumed empty second branch cannot be anchored. Demonstrated by test patterns
180such as /(?(1)^())b/ or /(?(?=^))b/.
181
18240. A repeated conditional subpattern that could match an empty string was
183always assumed to be unanchored. Now it it checked just like any other
184repeated conditional subpattern, and can be found to be anchored if the minimum
185quantifier is one or more. I can't see much use for a repeated anchored
186pattern, but the behaviour is now consistent.
187
18841. Minor addition to pcre2_jit_compile.c to avoid static analyzer complaint
189(for an event that could never occur but you had to have external information
190to know that).
191
19242. If before the first match in a file that was being searched by pcre2grep
193there was a line that was sufficiently long to cause the input buffer to be
194expanded, the variable holding the location of the end of the previous match
195was being adjusted incorrectly, and could cause an overflow warning from a code
196sanitizer. However, as the value is used only to print pending "after" lines
197when the next match is reached (and there are no such lines in this case) this
198bug could do no damage.
199
200
Elliott Hughes9bc971b2018-07-27 13:23:14 -0700201Version 10.31 12-February-2018
202------------------------------
203
2041. Fix typo (missing ]) in VMS code in pcre2test.c.
205
2062. Replace the replicated code for matching extended Unicode grapheme sequences
207(which got a lot more complicated by change 10.30/49) by a single subroutine
208that is called by both pcre2_match() and pcre2_dfa_match().
209
2103. Add idempotent guard to pcre2_internal.h.
211
2124. Add new pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and
213PCRE2_CONFIG_COMPILED_WIDTHS.
214
2155. Cut out \C tests in the JIT regression tests when NEVER_BACKSLASH_C is
216defined (e.g. by --enable-never-backslash-C).
217
2186. Defined public names for all the pcre2_compile() error numbers, and used
219the public names in pcre2_convert.c.
220
2217. Fixed a small memory leak in pcre2test (convert contexts).
222
2238. Added two casts to compile.c and one to match.c to avoid compiler warnings.
224
2259. Added code to pcre2grep when compiled under VMS to set the symbol
226PCRE2GREP_RC to the exit status, because VMS does not distinguish between
227exit(0) and exit(1).
228
22910. Added the -LM (list modifiers) option to pcre2test. Also made -C complain
230about a bad option only if the following argument item does not start with a
231hyphen.
232
23311. pcre2grep was truncating components of file names to 128 characters when
234processing files with the -r option, and also (some very odd code) truncating
235path names to 512 characters. There is now a check on the absolute length of
236full path file names, which may be up to 2047 characters long.
237
23812. When an assertion contained (*ACCEPT) it caused all open capturing groups
239to be closed (as for a non-assertion ACCEPT), which was wrong and could lead to
240misbehaviour for subsequent references to groups that started outside the
241assertion. ACCEPT in an assertion now closes only those groups that were
242started within that assertion. Fixes oss-fuzz issues 3852 and 3891.
243
24413. Multiline matching in pcre2grep was misbehaving if the pattern matched
245within a line, and then matched again at the end of the line and over into
246subsequent lines. Behaviour was different with and without colouring, and
247sometimes context lines were incorrectly printed and/or line endings were lost.
248All these issues should now be fixed.
249
25014. If --line-buffered was specified for pcre2grep when input was from a
251compressed file (.gz or .bz2) a segfault occurred. (Line buffering should be
252ignored for compressed files.)
253
25415. Although pcre2_jit_match checks whether the pattern is compiled
255in a given mode, it was also expected that at least one mode is available.
256This is fixed and pcre2_jit_match returns with PCRE2_ERROR_JIT_BADOPTION
257when the pattern is not optimized by JIT at all.
258
25916. The line number and related variables such as match counts in pcre2grep
260were all int variables, causing overflow when files with more than 2147483647
261lines were processed (assuming 32-bit ints). They have all been changed to
262unsigned long ints.
263
26417. If a backreference with a minimum repeat count of zero was first in a
265pattern, apart from assertions, an incorrect first matching character could be
266recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set
267as the first character of a match.
268
26918. Characters in a leading positive assertion are considered for recording a
270first character of a match when the rest of the pattern does not provide one.
271However, a character in a non-assertive group within a leading assertion such
272as in the pattern /(?=(a))\1?b/ caused this process to fail. This was an
273infelicity rather than an outright bug, because it did not affect the result of
274a match, just its speed. (In fact, in this case, the starting 'a' was
275subsequently picked up in the study.)
276
27719. A minor tidy in pcre2_match(): making all PCRE2_ERROR_ returns use "return"
278instead of "RRETURN" saves unwinding the backtracks in these cases (only one
279didn't).
280
28120. Allocate a single callout block on the stack at the start of pcre2_match()
282and set its never-changing fields once only. Do the same for pcre2_dfa_match().
283
28421. Save the extra compile options (set in the compile context) with the
285compiled pattern (they were not previously saved), add PCRE2_INFO_EXTRAOPTIONS
286to retrieve them, and update pcre2test to show them.
287
28822. Added PCRE2_CALLOUT_STARTMATCH and PCRE2_CALLOUT_BACKTRACK bits to a new
289field callout_flags in callout blocks. The bits are set by pcre2_match(), but
290not by JIT or pcre2_dfa_match(). Their settings are shown in pcre2test callouts
291if the callout_extra subject modifier is set. These bits are provided to help
292with tracking how a backtracking match is proceeding.
293
29423. Updated the pcre2demo.c demonstration program, which was missing the extra
295code for -g that handles the case when \K in an assertion causes the match to
296end at the original start point. Also arranged for it to detect when \K causes
297the end of a match to be before its start.
298
29924. Similar to 23 above, strange things (including loops) could happen in
300pcre2grep when \K was used in an assertion when --colour was used or in
301multiline mode. The "end at original start point" bug is fixed, and if the end
302point is found to be before the start point, they are swapped.
303
30425. When PCRE2_FIRSTLINE without PCRE2_NO_START_OPTIMIZE was used in non-JIT
305matching (both pcre2_match() and pcre2_dfa_match()) and the matched string
306started with the first code unit of a newline sequence, matching failed because
307it was not tried at the newline.
308
30926. Code for giving up a non-partial match after failing to find a starting
310code unit anywhere in the subject was missing when searching for one of a
311number of code units (the bitmap case) in both pcre2_match() and
312pcre2_dfa_match(). This was a missing optimization rather than a bug.
313
31427. Tidied up the ACROSSCHAR macro to be like FORWARDCHAR and BACKCHAR, using a
315pointer argument rather than a code unit value. This should not have affected
316the generated code.
317
31828. The JIT compiler has been updated.
319
32029. Avoid pointer overflow for unset captures in pcre2_substring_list_get().
321This could not actually cause a crash because it was always used in a memcpy()
322call with zero length.
323
32430. Some internal structures have a variable-length ovector[] as their last
325element. Their actual memory is obtained dynamically, giving an ovector of
326appropriate length. However, they are defined in the structure as
327ovector[NUMBER], where NUMBER is large so that array bound checkers don't
328grumble. The value of NUMBER was 10000, but a fuzzer exceeded 5000 capturing
329groups, making the ovector larger than this. The number has been increased to
330131072, which allows for the maximum number of captures (65535) plus the
331overall match. This fixes oss-fuzz issue 5415.
332
33331. Auto-possessification at the end of a capturing group was dependent on what
334follows the group (e.g. /(a+)b/ would auto-possessify the a+) but this caused
335incorrect behaviour when the group was called recursively from elsewhere in the
336pattern where something different might follow. This bug is an unforseen
337consequence of change #1 for 10.30 - the implementation of backtracking into
338recursions. Iterators at the ends of capturing groups are no longer considered
339for auto-possessification if the pattern contains any recursions. Fixes
340Bugzilla #2232.
341
342
343Version 10.30 14-August-2017
344----------------------------
345
3461. The main interpreter, pcre2_match(), has been refactored into a new version
347that does not use recursive function calls (and therefore the stack) for
348remembering backtracking positions. This makes --disable-stack-for-recursion a
349NOOP. The new implementation allows backtracking into recursive group calls in
350patterns, making it more compatible with Perl, and also fixes some other
351hard-to-do issues such as #1887 in Bugzilla. The code is also cleaner because
352the old code had a number of fudges to try to reduce stack usage. It seems to
353run no slower than the old code.
354
355A number of bugs in the refactored code were subsequently fixed during testing
356before release, but after the code was made available in the repository. These
357bugs were never in fully released code, but are noted here for the record.
358
359 (a) If a pattern had fewer capturing parentheses than the ovector supplied in
360 the match data block, a memory error (detectable by ASAN) occurred after
361 a match, because the external block was being set from non-existent
362 internal ovector fields. Fixes oss-fuzz issue 781.
363
364 (b) A pattern with very many capturing parentheses (when the internal frame
365 size was greater than the initial frame vector on the stack) caused a
366 crash. A vector on the heap is now set up at the start of matching if the
367 vector on the stack is not big enough to handle at least 10 frames.
368 Fixes oss-fuzz issue 783.
369
370 (c) Handling of (*VERB)s in recursions was wrong in some cases.
371
372 (d) Captures in negative assertions that were used as conditions were not
373 happening if the assertion matched via (*ACCEPT).
374
375 (e) Mark values were not being passed out of recursions.
376
377 (f) Refactor some code in do_callout() to avoid picky compiler warnings about
378 negative indices. Fixes oss-fuzz issue 1454.
379
380 (g) Similarly refactor the way the variable length ovector is addressed for
381 similar reasons. Fixes oss-fuzz issue 1465.
382
3832. Now that pcre2_match() no longer uses recursive function calls (see above),
384the "match limit recursion" value seems misnamed. It still exists, and limits
385the depth of tree that is searched. To avoid future confusion, it has been
386renamed as "depth limit" in all relevant places (--with-depth-limit,
387(*LIMIT_DEPTH), pcre2_set_depth_limit(), etc) but the old names are still
388available for backwards compatibility.
389
3903. Hardened pcre2test so as to reduce the number of bugs reported by fuzzers:
391
392 (a) Check for malloc failures when getting memory for the ovector (POSIX) or
393 the match data block (non-POSIX).
394
3954. In the 32-bit library in non-UTF mode, an attempt to find a Unicode property
396for a character with a code point greater than 0x10ffff (the Unicode maximum)
397caused a crash.
398
3995. If a lookbehind assertion that contained a back reference to a group
400appearing later in the pattern was compiled with the PCRE2_ANCHORED option,
401undefined actions (often a segmentation fault) could occur, depending on what
402other options were set. An example assertion is (?<!\1(abc)) where the
403reference \1 precedes the group (abc). This fixes oss-fuzz issue 865.
404
4056. Added the PCRE2_INFO_FRAMESIZE item to pcre2_pattern_info() and arranged for
406pcre2test to use it to output the frame size when the "framesize" modifier is
407given.
408
4097. Reworked the recursive pattern matching in the JIT compiler to follow the
410interpreter changes.
411
4128. When the zero_terminate modifier was specified on a pcre2test subject line
413for global matching, unpredictable things could happen. For example, in UTF-8
414mode, the pattern //g,zero_terminate read random memory when matched against an
415empty string with zero_terminate. This was a bug in pcre2test, not the library.
416
4179. Moved some Windows-specific code in pcre2grep (introduced in 10.23/13) out
418of the section that is compiled when Unix-style directory scanning is
419available, and into a new section that is always compiled for Windows.
420
42110. In pcre2test, explicitly close the file after an error during serialization
422or deserialization (the "load" or "save" commands).
423
42411. Fix memory leak in pcre2_serialize_decode() when the input is invalid.
425
42612. Fix potential NULL dereference in pcre2_callout_enumerate() if called with
427a NULL pattern pointer when Unicode support is available.
428
42913. When the 32-bit library was being tested by pcre2test, error messages that
430were longer than 64 code units could cause a buffer overflow. This was a bug in
431pcre2test.
432
43314. The alternative matching function, pcre2_dfa_match() misbehaved if it
434encountered a character class with a possessive repeat, for example [a-f]{3}+.
435
43615. The depth (formerly recursion) limit now applies to DFA matching (as
437of 10.23/36); pcre2test has been upgraded so that \=find_limits works with DFA
438matching to find the minimum value for this limit.
439
44016. Since 10.21, if pcre2_match() was called with a null context, default
441memory allocation functions were used instead of whatever was used when the
442pattern was compiled.
443
44417. Changes to the pcre2test "memory" modifier on a subject line. These apply
445only to pcre2_match():
446
447 (a) Warn if null_context is set on both pattern and subject, because the
448 memory details cannot then be shown.
449
450 (b) Remember (up to a certain number of) memory allocations and their
451 lengths, and list only the lengths, so as to be system-independent.
452 (In practice, the new interpreter never has more than 2 blocks allocated
453 simultaneously.)
454
45518. Make pcre2test detect an error return from pcre2_get_error_message(), give
456a message, and abandon the run (this would have detected #13 above).
457
45819. Implemented PCRE2_ENDANCHORED.
459
46020. Applied Jason Hood's patches (slightly modified) to pcre2grep, to implement
461the --output=text (-O) option and the inbuilt callout echo.
462
46321. Extend auto-anchoring etc. to ignore groups with a zero qualifier and
464single-branch conditions with a false condition (e.g. DEFINE) at the start of a
465branch. For example, /(?(DEFINE)...)^A/ and /(...){0}^B/ are now flagged as
466anchored.
467
46822. Added an explicit limit on the amount of heap used by pcre2_match(), set by
469pcre2_set_heap_limit() or (*LIMIT_HEAP=xxx). Upgraded pcre2test to show the
470heap limit along with other pattern information, and to find the minimum when
471the find_limits modifier is set.
472
47323. Write to the last 8 bytes of the pcre2_real_code structure when a compiled
474pattern is set up so as to initialize any padding the compiler might have
475included. This avoids valgrind warnings when a compiled pattern is copied, in
476particular when it is serialized.
477
47824. Remove a redundant line of code left in accidentally a long time ago.
479
48025. Remove a duplication typo in pcre2_tables.c
481
48226. Correct an incorrect cast in pcre2_valid_utf.c
483
48427. Update pcre2test, remove some unused code in pcre2_match(), and upgrade the
485tests to improve coverage.
486
48728. Some fixes/tidies as a result of looking at Coverity Scan output:
488
489 (a) Typo: ">" should be ">=" in opcode check in pcre2_auto_possess.c.
490 (b) Added some casts to avoid "suspicious implicit sign extension".
491 (c) Resource leaks in pcre2test in rare error cases.
492 (d) Avoid warning for never-use case OP_TABLE_LENGTH which is just a fudge
493 for checking at compile time that tables are the right size.
494 (e) Add missing "fall through" comment.
495
49629. Implemented PCRE2_EXTENDED_MORE and related /xx and (?xx) features.
497
49830. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
499
50031. If more than one of "push", "pushcopy", or "pushtablescopy" were set in
501pcre2test, a crash could occur.
502
Elliott Hughes653c2102019-01-09 15:41:36 -080050332. Make -bigstack in RunTest allocate a 64MiB stack (instead of 16MiB) so
504that all the tests can run with clang's sanitizing options.
Elliott Hughes9bc971b2018-07-27 13:23:14 -0700505
50633. Implement extra compile options in the compile context and add the first
507one: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES.
508
50934. Implement newline type PCRE2_NEWLINE_NUL.
510
51135. A lookbehind assertion that had a zero-length branch caused undefined
512behaviour when processed by pcre2_dfa_match(). This is oss-fuzz issue 1859.
513
51436. The match limit value now also applies to pcre2_dfa_match() as there are
515patterns that can use up a lot of resources without necessarily recursing very
516deeply. (Compare item 10.23/36.) This should fix oss-fuzz #1761.
517
51837. Implement PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
519
52038. Fix returned offsets from regexec() when REG_STARTEND is used with a
521starting offset greater than zero.
522
52339. Implement REG_PEND (GNU extension) for the POSIX wrapper.
524
52540. Implement the subject_literal modifier in pcre2test, and allow jitstack on
526pattern lines.
527
52841. Implement PCRE2_LITERAL and use it to support REG_NOSPEC.
529
53042. Implement PCRE2_EXTRA_MATCH_LINE and PCRE2_EXTRA_MATCH_WORD for the benefit
531of pcre2grep.
532
53343. Re-implement pcre2grep's -F, -w, and -x options using PCRE2_LITERAL,
534PCRE2_EXTRA_MATCH_WORD, and PCRE2_EXTRA_MATCH_LINE. This fixes two bugs:
535
536 (a) The -F option did not work for fixed strings containing \E.
537 (b) The -w option did not work for patterns with multiple branches.
538
53944. Added configuration options for the SELinux compatible execmem allocator in
540JIT.
541
54245. Increased the limit for searching for a "must be present" code unit in
543subjects from 1000 to 2000 for 8-bit searches, since they use memchr() and are
544much faster.
545
54646. Arrange for anchored patterns to record and use "first code unit" data,
547because this can give a fast "no match" without searching for a "required code
548unit". Previously only non-anchored patterns did this.
549
55047. Upgraded the Unicode tables from Unicode 8.0.0 to Unicode 10.0.0.
551
55248. Add the callout_no_where modifier to pcre2test.
553
55449. Update extended grapheme breaking rules to the latest set that are in
555Unicode Standard Annex #29.
556
55750. Added experimental foreign pattern conversion facilities
558(pcre2_pattern_convert() and friends).
559
56051. Change the macro FWRITE, used in pcre2grep, to FWRITE_IGNORE because FWRITE
561is defined in a system header in cygwin. Also modified some of the #ifdefs in
562pcre2grep related to Windows and Cygwin support.
563
56452. Change 3(g) for 10.23 was a bit too zealous. If a hyphen that follows a
565character class is the last character in the class, Perl does not give a
566warning. PCRE2 now also treats this as a literal.
567
56853. Related to 52, though PCRE2 was throwing an error for [[:digit:]-X] it was
569not doing so for [\d-X] (and similar escapes), as is documented.
570
57154. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard.
572
57355. Fixed a "maybe uninitialized" warning for class_uchardata in \p handling in
574pcre2_compile() which could never actually trigger (code should have been cut
575out when Unicode support is disabled).
576
577
578Version 10.23 14-February-2017
579------------------------------
580
5811. Extended pcre2test with the utf8_input modifier so that it is able to
582generate all possible 16-bit and 32-bit code unit values in non-UTF modes.
583
5842. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode), without
585PCRE2_UCP set, a negative character type such as \D in a positive class should
586cause all characters greater than 255 to match, whatever else is in the class.
587There was a bug that caused this not to happen if a Unicode property item was
588added to such a class, for example [\D\P{Nd}] or [\W\pL].
589
5903. There has been a major re-factoring of the pcre2_compile.c file. Most syntax
591checking is now done in the pre-pass that identifies capturing groups. This has
592reduced the amount of duplication and made the code tidier. While doing this,
593some minor bugs and Perl incompatibilities were fixed, including:
594
595 (a) \Q\E in the middle of a quantifier such as A+\Q\E+ is now ignored instead
596 of giving an invalid quantifier error.
597
598 (b) {0} can now be used after a group in a lookbehind assertion; previously
599 this caused an "assertion is not fixed length" error.
600
601 (c) Perl always treats (?(DEFINE) as a "define" group, even if a group with
602 the name "DEFINE" exists. PCRE2 now does likewise.
603
604 (d) A recursion condition test such as (?(R2)...) must now refer to an
605 existing subpattern.
606
607 (e) A conditional recursion test such as (?(R)...) misbehaved if there was a
608 group whose name began with "R".
609
610 (f) When testing zero-terminated patterns under valgrind, the terminating
611 zero is now marked "no access". This catches bugs that would otherwise
612 show up only with non-zero-terminated patterns.
613
614 (g) A hyphen appearing immediately after a POSIX character class (for example
615 /[[:ascii:]-z]/) now generates an error. Perl does accept this as a
616 literal, but gives a warning, so it seems best to fail it in PCRE.
617
618 (h) An empty \Q\E sequence may appear after a callout that precedes an
619 assertion condition (it is, of course, ignored).
620
621One effect of the refactoring is that some error numbers and messages have
622changed, and the pattern offset given for compiling errors is not always the
623right-most character that has been read. In particular, for a variable-length
624lookbehind assertion it now points to the start of the assertion. Another
625change is that when a callout appears before a group, the "length of next
626pattern item" that is passed now just gives the length of the opening
627parenthesis item, not the length of the whole group. A length of zero is now
628given only for a callout at the end of the pattern. Automatic callouts are no
629longer inserted before and after explicit callouts in the pattern.
630
631A number of bugs in the refactored code were subsequently fixed during testing
632before release, but after the code was made available in the repository. Many
633of the bugs were discovered by fuzzing testing. Several of them were related to
634the change from assuming a zero-terminated pattern (which previously had
635required non-zero terminated strings to be copied). These bugs were never in
636fully released code, but are noted here for the record.
637
638 (a) An overall recursion such as (?0) inside a lookbehind assertion was not
639 being diagnosed as an error.
640
641 (b) In utf mode, the length of a *MARK (or other verb) name was being checked
642 in characters instead of code units, which could lead to bad code being
643 compiled, leading to unpredictable behaviour.
644
645 (c) In extended /x mode, characters whose code was greater than 255 caused
646 a lookup outside one of the global tables. A similar bug existed for wide
647 characters in *VERB names.
648
649 (d) The amount of memory needed for a compiled pattern was miscalculated if a
650 lookbehind contained more than one toplevel branch and the first branch
651 was of length zero.
652
653 (e) In UTF-8 or UTF-16 modes with PCRE2_EXTENDED (/x) set and a non-zero-
654 terminated pattern, if a # comment ran on to the end of the pattern, one
655 or more code units past the end were being read.
656
657 (f) An unterminated repeat at the end of a non-zero-terminated pattern (e.g.
658 "{2,2") could cause reading beyond the pattern.
659
660 (g) When reading a callout string, if the end delimiter was at the end of the
661 pattern one further code unit was read.
662
663 (h) An unterminated number after \g' could cause reading beyond the pattern.
664
665 (i) An insufficient memory size was being computed for compiling with
666 PCRE2_AUTO_CALLOUT.
667
668 (j) A conditional group with an assertion condition used more memory than was
669 allowed for it during parsing, so too many of them could therefore
670 overrun a buffer.
671
672 (k) If parsing a pattern exactly filled the buffer, the internal test for
673 overrun did not check when the final META_END item was added.
674
675 (l) If a lookbehind contained a subroutine call, and the called group
676 contained an option setting such as (?s), and the PCRE2_ANCHORED option
677 was set, unpredictable behaviour could occur. The underlying bug was
678 incorrect code and insufficient checking while searching for the end of
679 the called subroutine in the parsed pattern.
680
681 (m) Quantifiers following (*VERB)s were not being diagnosed as errors.
682
683 (n) The use of \Q...\E in a (*VERB) name when PCRE2_ALT_VERBNAMES and
684 PCRE2_AUTO_CALLOUT were both specified caused undetermined behaviour.
685
686 (o) If \Q was preceded by a quantified item, and the following \E was
687 followed by '?' or '+', and there was at least one literal character
688 between them, an internal error "unexpected repeat" occurred (example:
689 /.+\QX\E+/).
690
691 (p) A buffer overflow could occur while sorting the names in the group name
692 list (depending on the order in which the names were seen).
693
694 (q) A conditional group that started with a callout was not doing the right
695 check for a following assertion, leading to compiling bad code. Example:
696 /(?(C'XX))?!XX/
697
698 (r) If a character whose code point was greater than 0xffff appeared within
699 a lookbehind that was within another lookbehind, the calculation of the
700 lookbehind length went wrong and could provoke an internal error.
701
702 (t) The sequence \E- or \Q\E- after a POSIX class in a character class caused
703 an internal error. Now the hyphen is treated as a literal.
704
7054. Back references are now permitted in lookbehind assertions when there are
706no duplicated group numbers (that is, (?| has not been used), and, if the
707reference is by name, there is only one group of that name. The referenced
708group must, of course be of fixed length.
709
7105. pcre2test has been upgraded so that, when run under valgrind with valgrind
711support enabled, reading past the end of the pattern is detected, both when
712compiling and during callout processing.
713
7146. \g{+<number>} (e.g. \g{+2} ) is now supported. It is a "forward back
715reference" and can be useful in repetitions (compare \g{-<number>} ). Perl does
716not recognize this syntax.
717
7187. Automatic callouts are no longer generated before and after callouts in the
719pattern.
720
7218. When pcre2test was outputing information from a callout, the caret indicator
722for the current position in the subject line was incorrect if it was after an
723escape sequence for a character whose code point was greater than \x{ff}.
724
7259. Change 19 for 10.22 had a typo (PCRE_STATIC_RUNTIME should be
726PCRE2_STATIC_RUNTIME). Fix from David Gaussmann.
727
72810. Added --max-buffer-size to pcre2grep, to allow for automatic buffer
729expansion when long lines are encountered. Original patch by Dmitry
730Cherniachenko.
731
73211. If pcre2grep was compiled with JIT support, but the library was compiled
733without it (something that neither ./configure nor CMake allow, but it can be
734done by editing config.h), pcre2grep was giving a JIT error. Now it detects
735this situation and does not try to use JIT.
736
73712. Added some "const" qualifiers to variables in pcre2grep.
738
73913. Added Dmitry Cherniachenko's patch for colouring output in Windows
740(untested by me). Also, look for GREP_COLOUR or GREP_COLOR if the environment
741variables PCRE2GREP_COLOUR and PCRE2GREP_COLOR are not found.
742
74314. Add the -t (grand total) option to pcre2grep.
744
74515. A number of bugs have been mended relating to match start-up optimizations
746when the first thing in a pattern is a positive lookahead. These all applied
747only when PCRE2_NO_START_OPTIMIZE was *not* set:
748
749 (a) A pattern such as (?=.*X)X$ was incorrectly optimized as if it needed
750 both an initial 'X' and a following 'X'.
751 (b) Some patterns starting with an assertion that started with .* were
752 incorrectly optimized as having to match at the start of the subject or
753 after a newline. There are cases where this is not true, for example,
754 (?=.*[A-Z])(?=.{8,16})(?!.*[\s]) matches after the start in lines that
755 start with spaces. Starting .* in an assertion is no longer taken as an
756 indication of matching at the start (or after a newline).
757
75816. The "offset" modifier in pcre2test was not being ignored (as documented)
759when the POSIX API was in use.
760
76117. Added --enable-fuzz-support to "configure", causing an non-installed
762library containing a test function that can be called by fuzzers to be
763compiled. A non-installed binary to run the test function locally, called
764pcre2fuzzcheck is also compiled.
765
76618. A pattern with PCRE2_DOTALL (/s) set but not PCRE2_NO_DOTSTAR_ANCHOR, and
767which started with .* inside a positive lookahead was incorrectly being
768compiled as implicitly anchored.
769
77019. Removed all instances of "register" declarations, as they are considered
771obsolete these days and in any case had become very haphazard.
772
77320. Add strerror() to pcre2test for failed file opening.
774
77521. Make pcre2test -C list valgrind support when it is enabled.
776
77722. Add the use_length modifier to pcre2test.
778
77923. Fix an off-by-one bug in pcre2test for the list of names for 'get' and
780'copy' modifiers.
781
78224. Add PCRE2_CALL_CONVENTION into the prototype declarations in pcre2.h as it
783is apparently needed there as well as in the function definitions. (Why did
784nobody ask for this in PCRE1?)
785
78625. Change the _PCRE2_H and _PCRE2_UCP_H guard macros in the header files to
787PCRE2_H_IDEMPOTENT_GUARD and PCRE2_UCP_H_IDEMPOTENT_GUARD to be more standard
788compliant and unique.
789
79026. pcre2-config --libs-posix was listing -lpcre2posix instead of
791-lpcre2-posix. Also, the CMake build process was building the library with the
792wrong name.
793
79427. In pcre2test, give some offset information for errors in hex patterns.
795This uses the C99 formatting sequence %td, except for MSVC which doesn't
796support it - %lu is used instead.
797
79828. Implemented pcre2_code_copy_with_tables(), and added pushtablescopy to
799pcre2test for testing it.
800
80129. Fix small memory leak in pcre2test.
802
80330. Fix out-of-bounds read for partial matching of /./ against an empty string
804when the newline type is CRLF.
805
80631. Fix a bug in pcre2test that caused a crash when a locale was set either in
807the current pattern or a previous one and a wide character was matched.
808
80932. The appearance of \p, \P, or \X in a substitution string when
810PCRE2_SUBSTITUTE_EXTENDED was set caused a segmentation fault (NULL
811dereference).
812
81333. If the starting offset was specified as greater than the subject length in
814a call to pcre2_substitute() an out-of-bounds memory reference could occur.
815
81634. When PCRE2 was compiled to use the heap instead of the stack for recursive
817calls to match(), a repeated minimizing caseless back reference, or a
818maximizing one where the two cases had different numbers of code units,
819followed by a caseful back reference, could lose the caselessness of the first
820repeated back reference (example: /(Z)(a)\2{1,2}?(?-i)\1X/i should match ZaAAZX
821but didn't).
822
82335. When a pattern is too complicated, PCRE2 gives up trying to find a minimum
824matching length and just records zero. Typically this happens when there are
825too many nested or recursive back references. If the limit was reached in
826certain recursive cases it failed to be triggered and an internal error could
827be the result.
828
82936. The pcre2_dfa_match() function now takes note of the recursion limit for
830the internal recursive calls that are used for lookrounds and recursions within
831the pattern.
832
83337. More refactoring has got rid of the internal could_be_empty_branch()
834function (around 400 lines of code, including comments) by keeping track of
835could-be-emptiness as the pattern is compiled instead of scanning compiled
836groups. (This would have been much harder before the refactoring of #3 above.)
837This lifts a restriction on the number of branches in a group (more than about
8381100 would give "pattern is too complicated").
839
84038. Add the "-ac" command line option to pcre2test as a synonym for "-pattern
841auto_callout".
842
84339. In a library with Unicode support, incorrect data was compiled for a
844pattern with PCRE2_UCP set without PCRE2_UTF if a class required all wide
845characters to match (for example, /[\s[:^ascii:]]/).
846
84740. The callout_error modifier has been added to pcre2test to make it possible
848to return PCRE2_ERROR_CALLOUT from a callout.
849
85041. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of
851"<esc>[00m".
852
85342. The limit in the auto-possessification code that was intended to catch
854overly-complicated patterns and not spend too much time auto-possessifying was
855being reset too often, resulting in very long compile times for some patterns.
856Now such patterns are no longer completely auto-possessified.
857
85843. Applied Jason Hood's revised patch for RunTest.bat.
859
86044. Added a new Windows script RunGrepTest.bat, courtesy of Jason Hood.
861
86245. Minor cosmetic fix to pcre2test: move a variable that is not used under
863Windows into the "not Windows" code.
864
86546. Applied Jason Hood's patches to upgrade pcre2grep under Windows and tidy
866some of the code:
867
868 * normalised the Windows condition by ensuring WIN32 is defined;
869 * enables the callout feature under Windows;
870 * adds globbing (Microsoft's implementation expands quoted args),
871 using a tweaked opendirectory;
872 * implements the is_*_tty functions for Windows;
873 * --color=always will write the ANSI sequences to file;
874 * add sequences 4 (underline works on Win10) and 5 (blink as bright
875 background, relatively standard on DOS/Win);
876 * remove the (char *) casts for the now-const strings;
877 * remove GREP_COLOUR (grep's command line allowed the 'u', but not
878 the environment), parsing GREP_COLORS instead;
879 * uses the current colour if not set, rather than black;
880 * add print_match for the undefined case;
881 * fixes a typo.
882
883In addition, colour settings containing anything other than digits and
884semicolon are ignored, and the colour controls are no longer output for empty
885strings.
886
88747. Detecting patterns that are too large inside the length-measuring loop
888saves processing ridiculously long patterns to their end.
889
89048. Ignore PCRE2_CASELESS when processing \h, \H, \v, and \V in classes as it
891just wastes time. In the UTF case it can also produce redundant entries in
892XCLASS lists caused by characters with multiple other cases and pairs of
893characters in the same "not-x" sublists.
894
89549. A pattern such as /(?=(a\K))/ can report the end of the match being before
896its start; pcre2test was not handling this correctly when using the POSIX
897interface (it was OK with the native interface).
898
89950. In pcre2grep, ignore all JIT compile errors. This means that pcre2grep will
900continue to work, falling back to interpretation if anything goes wrong with
901JIT.
902
90351. Applied patches from Christian Persch to configure.ac to make use of the
904AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT
905modules.
906
90752. Minor fixes to pcre2grep from Jason Hood:
908 * fixed some spacing;
909 * Windows doesn't usually use single quotes, so I've added a define
910 to use appropriate quotes [in an example];
911 * LC_ALL was displayed as "LCC_ALL";
912 * numbers 11, 12 & 13 should end in "th";
913 * use double quotes in usage message.
914
91553. When autopossessifying, skip empty branches without recursion, to reduce
916stack usage for the benefit of clang with -fsanitize-address, which uses huge
917stack frames. Example pattern: /X?(R||){3335}/. Fixes oss-fuzz issue 553.
918
91954. A pattern with very many explicit back references to a group that is a long
920way from the start of the pattern could take a long time to compile because
921searching for the referenced group in order to find the minimum length was
922being done repeatedly. Now up to 128 group minimum lengths are cached and the
923attempt to find a minimum length is abandoned if there is a back reference to a
924group whose number is greater than 128. (In that case, the pattern is so
925complicated that this optimization probably isn't worth it.) This fixes
926oss-fuzz issue 557.
927
92855. Issue 32 for 10.22 below was not correctly fixed. If pcre2grep in multiline
929mode with --only-matching matched several lines, it restarted scanning at the
930next line instead of moving on to the end of the matched string, which can be
931several lines after the start.
932
93356. Applied Jason Hood's new patch for RunGrepTest.bat that updates it in line
934with updates to the non-Windows version.
935
936
937
Janis Danisevskis8b979b22016-08-15 16:09:16 +0100938Version 10.22 29-July-2016
939--------------------------
940
9411. Applied Jason Hood's patches to RunTest.bat and testdata/wintestoutput3
942to fix problems with running the tests under Windows.
943
9442. Implemented a facility for quoting literal characters within hexadecimal
945patterns in pcre2test, to make it easier to create patterns with just a few
946non-printing characters.
947
9483. Binary zeros are not supported in pcre2test input files. It now detects them
949and gives an error.
950
9514. Updated the valgrind parameters in RunTest: (a) changed smc-check=all to
952smc-check=all-non-file; (b) changed obj:* in the suppression file to obj:??? so
953that it matches only unknown objects.
954
9555. Updated the maintenance script maint/ManyConfigTests to make it easier to
956select individual groups of tests.
957
9586. When the POSIX wrapper function regcomp() is called, the REG_NOSUB option
959used to set PCRE2_NO_AUTO_CAPTURE when calling pcre2_compile(). However, this
960disables the use of back references (and subroutine calls), which are supported
961by other implementations of regcomp() with RE_NOSUB. Therefore, REG_NOSUB no
962longer causes PCRE2_NO_AUTO_CAPTURE to be set, though it still ignores nmatch
963and pmatch when regexec() is called.
964
9657. Because of 6 above, pcre2test has been modified with a new modifier called
966posix_nosub, to call regcomp() with REG_NOSUB. Previously the no_auto_capture
967modifier had this effect. That option is now ignored when the POSIX API is in
968use.
969
9708. Minor tidies to the pcre2demo.c sample program, including more comments
971about its 8-bit-ness.
972
9739. Detect unmatched closing parentheses and give the error in the pre-scan
974instead of later. Previously the pre-scan carried on and could give a
975misleading incorrect error message. For example, /(?J)(?'a'))(?'a')/ gave a
976message about invalid duplicate group names.
977
97810. It has happened that pcre2test was accidentally linked with another POSIX
979regex library instead of libpcre2-posix. In this situation, a call to regcomp()
980(in the other library) may succeed, returning zero, but of course putting its
981own data into the regex_t block. In one example the re_pcre2_code field was
982left as NULL, which made pcre2test think it had not got a compiled POSIX regex,
983so it treated the next line as another pattern line, resulting in a confusing
984error message. A check has been added to pcre2test to see if the data returned
985from a successful call of regcomp() are valid for PCRE2's regcomp(). If they
986are not, an error message is output and the pcre2test run is abandoned. The
987message points out the possibility of a mis-linking. Hopefully this will avoid
988some head-scratching the next time this happens.
989
99011. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind
991assertion, caused pcre2test to output a very large number of spaces when the
992callout was taken, making the program appearing to loop.
993
99412. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
995nested set of parentheses of sufficient size caused an overflow of the
996compiling workspace (which was diagnosed, but of course is not desirable).
997
99813. Detect missing closing parentheses during the pre-pass for group
999identification.
1000
100114. Changed some integer variable types and put in a number of casts, following
1002a report of compiler warnings from Visual Studio 2013 and a few tests with
1003gcc's -Wconversion (which still throws up a lot).
1004
100515. Implemented pcre2_code_copy(), and added pushcopy and #popcopy to pcre2test
1006for testing it.
1007
100816. Change 66 for 10.21 introduced the use of snprintf() in PCRE2's version of
1009regerror(). When the error buffer is too small, my version of snprintf() puts a
1010binary zero in the final byte. Bug #1801 seems to show that other versions do
1011not do this, leading to bad output from pcre2test when it was checking for
1012buffer overflow. It no longer assumes a binary zero at the end of a too-small
1013regerror() buffer.
1014
101517. Fixed typo ("&&" for "&") in pcre2_study(). Fortunately, this could not
1016actually affect anything, by sheer luck.
1017
101818. Two minor fixes for MSVC compilation: (a) removal of apparently incorrect
1019"const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for
1020older MSVC compilers. This has been done both in src/pcre2_internal.h for most
1021of the library, and also in src/pcre2posix.c, which no longer includes
1022pcre2_internal.h (see 24 below).
1023
102419. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
1025static compilation. Subsequently applied Chris Wilson's second patch, putting
1026the first patch under a new option instead of being unconditional when
1027PCRE_STATIC is set.
1028
102920. Updated pcre2grep to set stdout as binary when run under Windows, so as not
1030to convert \r\n at the ends of reflected lines into \r\r\n. This required
1031ensuring that other output that is written to stdout (e.g. file names) uses the
1032appropriate line terminator: \r\n for Windows, \n otherwise.
1033
103421. When a line is too long for pcre2grep's internal buffer, show the maximum
1035length in the error message.
1036
103722. Added support for string callouts to pcre2grep (Zoltan's patch with PH
1038additions).
1039
104023. RunTest.bat was missing a "set type" line for test 22.
1041
104224. The pcre2posix.c file was including pcre2_internal.h, and using some
1043"private" knowledge of the data structures. This is unnecessary; the code has
1044been re-factored and no longer includes pcre2_internal.h.
1045
104625. A racing condition is fixed in JIT reported by Mozilla.
1047
104826. Minor code refactor to avoid "array subscript is below array bounds"
1049compiler warning.
1050
105127. Minor code refactor to avoid "left shift of negative number" warning.
1052
105328. Add a bit more sanity checking to pcre2_serialize_decode() and document
1054that it expects trusted data.
1055
105629. Fix typo in pcre2_jit_test.c
1057
105830. Due to an oversight, pcre2grep was not making use of JIT when available.
1059This is now fixed.
1060
106131. The RunGrepTest script is updated to use the valgrind suppressions file
1062when testing with JIT under valgrind (compare 10.21/51 below). The suppressions
1063file is updated so that is now the same as for PCRE1: it suppresses the
1064Memcheck warnings Addr16 and Cond in unknown objects (that is, JIT-compiled
1065code). Also changed smc-check=all to smc-check=all-non-file as was done for
1066RunTest (see 4 above).
1067
106832. Implemented the PCRE2_NO_JIT option for pcre2_match().
1069
107033. Fix typo that gave a compiler error when JIT not supported.
1071
107234. Fix comment describing the returns from find_fixedlength().
1073
107435. Fix potential negative index in pcre2test.
1075
107636. Calls to pcre2_get_error_message() with error numbers that are never
1077returned by PCRE2 functions were returning empty strings. Now the error code
1078PCRE2_ERROR_BADDATA is returned. A facility has been added to pcre2test to
1079show the texts for given error numbers (i.e. to call pcre2_get_error_message()
1080and display what it returns) and a few representative error codes are now
1081checked in RunTest.
1082
108337. Added "&& !defined(__INTEL_COMPILER)" to the test for __GNUC__ in
1084pcre2_match.c, in anticipation that this is needed for the same reason it was
1085recently added to pcrecpp.cc in PCRE1.
1086
108738. Using -o with -M in pcre2grep could cause unnecessary repeated output when
1088the match extended over a line boundary, as it tried to find more matches "on
1089the same line" - but it was already over the end.
1090
109139. Allow \C in lookbehinds and DFA matching in UTF-32 mode (by converting it
1092to the same code as '.' when PCRE2_DOTALL is set).
1093
109440. Fix two clang compiler warnings in pcre2test when only one code unit width
1095is supported.
1096
Elliott Hughes653c2102019-01-09 15:41:36 -0800109741. Upgrade RunTest to automatically re-run test 2 with a large (64MiB) stack
1098if it fails when running the interpreter with a 16MiB stack (and if changing
1099the stack size via pcre2test is possible). This avoids having to manually set a
Janis Danisevskis8b979b22016-08-15 16:09:16 +01001100large stack size when testing with clang.
1101
110242. Fix register overwite in JIT when SSE2 acceleration is enabled.
1103
110443. Detect integer overflow in pcre2test pattern and data repetition counts.
1105
110644. In pcre2test, ignore "allcaptures" after DFA matching.
1107
110845. Fix unaligned accesses on x86. Patch by Marc Mutz.
1109
111046. Fix some more clang compiler warnings.
1111
1112
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001113Version 10.21 12-January-2016
1114-----------------------------
1115
11161. Improve matching speed of patterns starting with + or * in JIT.
1117
11182. Use memchr() to find the first character in an unanchored match in 8-bit
1119mode in the interpreter. This gives a significant speed improvement.
1120
11213. Removed a redundant copy of the opcode_possessify table in the
1122pcre2_auto_possessify.c source.
1123
11244. Fix typos in dftables.c for z/OS.
1125
11265. Change 36 for 10.20 broke the handling of [[:>:]] and [[:<:]] in that
1127processing them could involve a buffer overflow if the following character was
1128an opening parenthesis.
1129
11306. Change 36 for 10.20 also introduced a bug in processing this pattern:
1131/((?x)(*:0))#(?'/. Specifically: if a setting of (?x) was followed by a (*MARK)
1132setting (which (*:0) is), then (?x) did not get unset at the end of its group
1133during the scan for named groups, and hence the external # was incorrectly
1134treated as a comment and the invalid (?' at the end of the pattern was not
1135diagnosed. This caused a buffer overflow during the real compile. This bug was
1136discovered by Karl Skomski with the LLVM fuzzer.
1137
11387. Moved the pcre2_find_bracket() function from src/pcre2_compile.c into its
1139own source module to avoid a circular dependency between src/pcre2_compile.c
1140and src/pcre2_study.c
1141
11428. A callout with a string argument containing an opening square bracket, for
1143example /(?C$[$)(?<]/, was incorrectly processed and could provoke a buffer
1144overflow. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1145
11469. The handling of callouts during the pre-pass for named group identification
1147has been tightened up.
1148
114910. The quantifier {1} can be ignored, whether greedy, non-greedy, or
1150possessive. This is a very minor optimization.
1151
115211. A possessively repeated conditional group that could match an empty string,
1153for example, /(?(R))*+/, was incorrectly compiled.
1154
115512. The Unicode tables have been updated to Unicode 8.0.0 (thanks to Christian
1156Persch).
1157
115813. An empty comment (?#) in a pattern was incorrectly processed and could
1159provoke a buffer overflow. This bug was discovered by Karl Skomski with the
1160LLVM fuzzer.
1161
116214. Fix infinite recursion in the JIT compiler when certain patterns such as
1163/(?:|a|){100}x/ are analysed.
1164
116515. Some patterns with character classes involving [: and \\ were incorrectly
1166compiled and could cause reading from uninitialized memory or an incorrect
1167error diagnosis. Examples are: /[[:\\](?<[::]/ and /[[:\\](?'abc')[a:]. The
1168first of these bugs was discovered by Karl Skomski with the LLVM fuzzer.
1169
117016. Pathological patterns containing many nested occurrences of [: caused
1171pcre2_compile() to run for a very long time. This bug was found by the LLVM
1172fuzzer.
1173
117417. A missing closing parenthesis for a callout with a string argument was not
1175being diagnosed, possibly leading to a buffer overflow. This bug was found by
1176the LLVM fuzzer.
1177
117818. A conditional group with only one branch has an implicit empty alternative
1179branch and must therefore be treated as potentially matching an empty string.
1180
118119. If (?R was followed by - or + incorrect behaviour happened instead of a
1182diagnostic. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1183
118420. Another bug that was introduced by change 36 for 10.20: conditional groups
1185whose condition was an assertion preceded by an explicit callout with a string
1186argument might be incorrectly processed, especially if the string contained \Q.
1187This bug was discovered by Karl Skomski with the LLVM fuzzer.
1188
118921. Compiling PCRE2 with the sanitize options of clang showed up a number of
1190very pedantic coding infelicities and a buffer overflow while checking a UTF-8
1191string if the final multi-byte UTF-8 character was truncated.
1192
119322. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
1194class, where both values are literal letters in the same case, omit the
1195non-letter EBCDIC code points within the range.
1196
119723. Finding the minimum matching length of complex patterns with back
1198references and/or recursions can take a long time. There is now a cut-off that
1199gives up trying to find a minimum length when things get too complex.
1200
120124. An optimization has been added that speeds up finding the minimum matching
1202length for patterns containing repeated capturing groups or recursions.
1203
120425. If a pattern contained a back reference to a group whose number was
1205duplicated as a result of appearing in a (?|...) group, the computation of the
1206minimum matching length gave a wrong result, which could cause incorrect "no
1207match" errors. For such patterns, a minimum matching length cannot at present
1208be computed.
1209
121026. Added a check for integer overflow in conditions (?(<digits>) and
1211(?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
1212fuzzer.
1213
121427. Fixed an issue when \p{Any} inside an xclass did not read the current
1215character.
1216
121728. If pcre2grep was given the -q option with -c or -l, or when handling a
1218binary file, it incorrectly wrote output to stdout.
1219
122029. The JIT compiler did not restore the control verb head in case of *THEN
1221control verbs. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1222
122330. The way recursive references such as (?3) are compiled has been re-written
1224because the old way was the cause of many issues. Now, conversion of the group
1225number into a pattern offset does not happen until the pattern has been
1226completely compiled. This does mean that detection of all infinitely looping
1227recursions is postponed till match time. In the past, some easy ones were
1228detected at compile time. This re-writing was done in response to yet another
1229bug found by the LLVM fuzzer.
1230
123131. A test for a back reference to a non-existent group was missing for items
1232such as \987. This caused incorrect code to be compiled. This issue was found
1233by Karl Skomski with a custom LLVM fuzzer.
1234
123532. Error messages for syntax errors following \g and \k were giving inaccurate
1236offsets in the pattern.
1237
123833. Improve the performance of starting single character repetitions in JIT.
1239
124034. (*LIMIT_MATCH=) now gives an error instead of setting the value to 0.
1241
124235. Error messages for syntax errors in *LIMIT_MATCH and *LIMIT_RECURSION now
1243give the right offset instead of zero.
1244
124536. The JIT compiler should not check repeats after a {0,1} repeat byte code.
1246This issue was found by Karl Skomski with a custom LLVM fuzzer.
1247
124837. The JIT compiler should restore the control chain for empty possessive
1249repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1250
125138. A bug which was introduced by the single character repetition optimization
1252was fixed.
1253
125439. Match limit check added to recursion. This issue was found by Karl Skomski
1255with a custom LLVM fuzzer.
1256
125740. Arrange for the UTF check in pcre2_match() and pcre2_dfa_match() to look
1258only at the part of the subject that is relevant when the starting offset is
1259non-zero.
1260
126141. Improve first character match in JIT with SSE2 on x86.
1262
126342. Fix two assertion fails in JIT. These issues were found by Karl Skomski
1264with a custom LLVM fuzzer.
1265
126643. Correct the setting of CMAKE_C_FLAGS in CMakeLists.txt (patch from Roy Ivy
1267III).
1268
126944. Fix bug in RunTest.bat for new test 14, and adjust the script for the added
1270test (there are now 20 in total).
1271
127245. Fixed a corner case of range optimization in JIT.
1273
127446. Add the ${*MARK} facility to pcre2_substitute().
1275
127647. Modifier lists in pcre2test were splitting at spaces without the required
1277commas.
1278
127948. Implemented PCRE2_ALT_VERBNAMES.
1280
128149. Fixed two issues in JIT. These were found by Karl Skomski with a custom
1282LLVM fuzzer.
1283
128450. The pcre2test program has been extended by adding the #newline_default
1285command. This has made it possible to run the standard tests when PCRE2 is
1286compiled with either CR or CRLF as the default newline convention. As part of
1287this work, the new command was added to several test files and the testing
1288scripts were modified. The pcre2grep tests can now also be run when there is no
1289LF in the default newline convention.
1290
129151. The RunTest script has been modified so that, when JIT is used and valgrind
1292is specified, a valgrind suppressions file is set up to ignore "Invalid read of
1293size 16" errors because these are false positives when the hardware supports
1294the SSE2 instruction set.
1295
129652. It is now possible to have comment lines amid the subject strings in
1297pcre2test (and perltest.sh) input.
1298
129953. Implemented PCRE2_USE_OFFSET_LIMIT and pcre2_set_offset_limit().
1300
130154. Add the null_context modifier to pcre2test so that calling pcre2_compile()
1302and the matching functions with NULL contexts can be tested.
1303
130455. Implemented PCRE2_SUBSTITUTE_EXTENDED.
1305
130656. In a character class such as [\W\p{Any}] where both a negative-type escape
1307("not a word character") and a property escape were present, the property
1308escape was being ignored.
1309
131057. Fixed integer overflow for patterns whose minimum matching length is very,
1311very large.
1312
131358. Implemented --never-backslash-C.
1314
131559. Change 55 above introduced a bug by which certain patterns provoked the
1316erroneous error "\ at end of pattern".
1317
131860. The special sequences [[:<:]] and [[:>:]] gave rise to incorrect compiling
1319errors or other strange effects if compiled in UCP mode. Found with libFuzzer
1320and AddressSanitizer.
1321
132261. Whitespace at the end of a pcre2test pattern line caused a spurious error
1323message if there were only single-character modifiers. It should be ignored.
1324
132562. The use of PCRE2_NO_AUTO_CAPTURE could cause incorrect compilation results
1326or segmentation errors for some patterns. Found with libFuzzer and
1327AddressSanitizer.
1328
132963. Very long names in (*MARK) or (*THEN) etc. items could provoke a buffer
1330overflow.
1331
133264. Improve error message for overly-complicated patterns.
1333
133465. Implemented an optional replication feature for patterns in pcre2test, to
1335make it easier to test long repetitive patterns. The tests for 63 above are
1336converted to use the new feature.
1337
133866. In the POSIX wrapper, if regerror() was given too small a buffer, it could
1339misbehave.
1340
134167. In pcre2_substitute() in UTF mode, the UTF validity check on the
1342replacement string was happening before the length setting when the replacement
1343string was zero-terminated.
1344
134568. In pcre2_substitute() in UTF mode, PCRE2_NO_UTF_CHECK can be set for the
1346second and subsequent calls to pcre2_match().
1347
134869. There was no check for integer overflow for a replacement group number in
1349pcre2_substitute(). An added check for a number greater than the largest group
1350number in the pattern means this is not now needed.
1351
135270. The PCRE2-specific VERSION condition didn't work correctly if only one
1353digit was given after the decimal point, or if more than two digits were given.
1354It now works with one or two digits, and gives a compile time error if more are
1355given.
1356
135771. In pcre2_substitute() there was the possibility of reading one code unit
1358beyond the end of the replacement string.
1359
136072. The code for checking a subject's UTF-32 validity for a pattern with a
1361lookbehind involved an out-of-bounds pointer, which could potentially cause
1362trouble in some environments.
1363
136473. The maximum lookbehind length was incorrectly calculated for patterns such
1365as /(?<=(a)(?-1))x/ which have a recursion within a backreference.
1366
136774. Give an error if a lookbehind assertion is longer than 65535 code units.
1368
136975. Give an error in pcre2_substitute() if a match ends before it starts (as a
1370result of the use of \K).
1371
137276. Check the length of subpattern names and the names in (*MARK:xx) etc.
1373dynamically to avoid the possibility of integer overflow.
1374
137577. Implement pcre2_set_max_pattern_length() so that programs can restrict the
1376size of patterns that they are prepared to handle.
1377
137878. (*NO_AUTO_POSSESS) was not working.
1379
138079. Adding group information caching improves the speed of compiling when
1381checking whether a group has a fixed length and/or could match an empty string,
1382especially when recursion or subroutine calls are involved. However, this
1383cannot be used when (?| is present in the pattern because the same number may
1384be used for groups of different sizes. To catch runaway patterns in this
1385situation, counts have been introduced to the functions that scan for empty
1386branches or compute fixed lengths.
1387
138880. Allow for the possibility of the size of the nest_save structure not being
1389a factor of the size of the compiling workspace (it currently is).
1390
139181. Check for integer overflow in minimum length calculation and cap it at
139265535.
1393
139482. Small optimizations in code for finding the minimum matching length.
1395
139683. Lock out configuring for EBCDIC with non-8-bit libraries.
1397
139884. Test for error code <= 0 in regerror().
1399
140085. Check for too many replacements (more than INT_MAX) in pcre2_substitute().
1401
140286. Avoid the possibility of computing with an out-of-bounds pointer (though
1403not dereferencing it) while handling lookbehind assertions.
1404
140587. Failure to get memory for the match data in regcomp() is now given as a
1406regcomp() error instead of waiting for regexec() to pick it up.
1407
140888. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
1409newline sequence.
1410
141189. Paranoid check in regcomp() for bad error code from pcre2_compile().
1412
141390. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
1414as for link size 2.
1415
141691. Document that JIT has a limit on pattern size, and give more information
1417about JIT compile failures in pcre2test.
1418
141992. Implement PCRE2_INFO_HASBACKSLASHC.
1420
142193. Re-arrange valgrind support code in pcre2test to avoid spurious reports
1422with JIT (possibly caused by SSE2?).
1423
142494. Support offset_limit in JIT.
1425
142695. A sequence such as [[:punct:]b] that is, a POSIX character class followed
1427by a single ASCII character in a class item, was incorrectly compiled in UCP
1428mode. The POSIX class got lost, but only if the single character followed it.
1429
143096. [:punct:] in UCP mode was matching some characters in the range 128-255
1431that should not have been matched.
1432
143397. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
1434characters with code points greater than 255 are in the class. When a Unicode
1435property was also in the class (if PCRE2_UCP is set, escapes such as \w are
1436turned into Unicode properties), wide characters were not correctly handled,
1437and could fail to match.
1438
143998. In pcre2test, make the "startoffset" modifier a synonym of "offset",
1440because it sets the "startoffset" parameter for pcre2_match().
1441
144299. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
1443an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
1444misbehaved. This bug was found by the LLVM fuzzer.
1445
1446100. The error for an invalid UTF pattern string always gave the code unit
1447offset as zero instead of where the invalidity was found.
1448
1449101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
1450working correctly in UCP mode.
1451
1452102. Similar to 99 above, if an isolated \E was present between an item and its
1453qualifier when PCRE2_AUTO_CALLOUT was set, pcre2_compile() misbehaved. This bug
1454was found by the LLVM fuzzer.
1455
1456103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
1457was set when the pmatch argument was NULL. It now returns REG_INVARG.
1458
1459104. Allow for up to 32-bit numbers in the ordin() function in pcre2grep.
1460
1461105. An empty \Q\E sequence between an item and its qualifier caused
1462pcre2_compile() to misbehave when auto callouts were enabled. This bug
1463was found by the LLVM fuzzer.
1464
1465106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
1466other verb "name" ended with whitespace immediately before the closing
1467parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
1468both those options were set.
1469
1470107. In a number of places pcre2_compile() was not handling NULL characters
1471correctly, and pcre2test with the "bincode" modifier was not always correctly
1472displaying fields containing NULLS:
1473
1474 (a) Within /x extended #-comments
1475 (b) Within the "name" part of (*MARK) and other *verbs
1476 (c) Within the text argument of a callout
1477
1478108. If a pattern that was compiled with PCRE2_EXTENDED started with white
1479space or a #-type comment that was followed by (?-x), which turns off
1480PCRE2_EXTENDED, and there was no subsequent (?x) to turn it on again,
1481pcre2_compile() assumed that (?-x) applied to the whole pattern and
1482consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix
Janis Danisevskis8b979b22016-08-15 16:09:16 +01001483for this bug means that a setting of any of the (?imsxJU) options at the start
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001484of a pattern is no longer transferred to the options that are returned by
1485PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have
1486changed when the effects of those options were all moved to compile time.
1487
1488109. An escaped closing parenthesis in the "name" part of a (*verb) when
1489PCRE2_ALT_VERBNAMES was set caused pcre2_compile() to malfunction. This bug
1490was found by the LLVM fuzzer.
1491
1492110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
1493possible to test it.
1494
1495111. "Harden" pcre2test against ridiculously large values in modifiers and
1496command line arguments.
1497
1498112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_
1499LENGTH.
1500
1501113. Fix printing of *MARK names that contain binary zeroes in pcre2test.
1502
1503
1504Version 10.20 30-June-2015
1505--------------------------
1506
15071. Callouts with string arguments have been added.
1508
15092. Assertion code generator in JIT has been optimized.
1510
15113. The invalid pattern (?(?C) has a missing assertion condition at the end. The
1512pcre2_compile() function read past the end of the input before diagnosing an
1513error. This bug was discovered by the LLVM fuzzer.
1514
15154. Implemented pcre2_callout_enumerate().
1516
15175. Fix JIT compilation of conditional blocks whose assertion is converted to
1518(*FAIL). E.g: /(?(?!))/.
1519
15206. The pattern /(?(?!)^)/ caused references to random memory. This bug was
1521discovered by the LLVM fuzzer.
1522
15237. The assertion (?!) is optimized to (*FAIL). This was not handled correctly
1524when this assertion was used as a condition, for example (?(?!)a|b). In
1525pcre2_match() it worked by luck; in pcre2_dfa_match() it gave an incorrect
1526error about an unsupported item.
1527
15288. For some types of pattern, for example /Z*(|d*){216}/, the auto-
1529possessification code could take exponential time to complete. A recursion
1530depth limit of 1000 has been imposed to limit the resources used by this
1531optimization. This infelicity was discovered by the LLVM fuzzer.
1532
15339. A pattern such as /(*UTF)[\S\V\H]/, which contains a negated special class
1534such as \S in non-UCP mode, explicit wide characters (> 255) can be ignored
1535because \S ensures they are all in the class. The code for doing this was
1536interacting badly with the code for computing the amount of space needed to
1537compile the pattern, leading to a buffer overflow. This bug was discovered by
1538the LLVM fuzzer.
1539
154010. A pattern such as /((?2)+)((?1))/ which has mutual recursion nested inside
1541other kinds of group caused stack overflow at compile time. This bug was
1542discovered by the LLVM fuzzer.
1543
154411. A pattern such as /(?1)(?#?'){8}(a)/ which had a parenthesized comment
1545between a subroutine call and its quantifier was incorrectly compiled, leading
1546to buffer overflow or other errors. This bug was discovered by the LLVM fuzzer.
1547
154812. The illegal pattern /(?(?<E>.*!.*)?)/ was not being diagnosed as missing an
1549assertion after (?(. The code was failing to check the character after (?(?<
1550for the ! or = that would indicate a lookbehind assertion. This bug was
1551discovered by the LLVM fuzzer.
1552
155313. A pattern such as /X((?2)()*+){2}+/ which has a possessive quantifier with
1554a fixed maximum following a group that contains a subroutine reference was
1555incorrectly compiled and could trigger buffer overflow. This bug was discovered
1556by the LLVM fuzzer.
1557
155814. Negative relative recursive references such as (?-7) to non-existent
1559subpatterns were not being diagnosed and could lead to unpredictable behaviour.
1560This bug was discovered by the LLVM fuzzer.
1561
156215. The bug fixed in 14 was due to an integer variable that was unsigned when
1563it should have been signed. Some other "int" variables, having been checked,
1564have either been changed to uint32_t or commented as "must be signed".
1565
156616. A mutual recursion within a lookbehind assertion such as (?<=((?2))((?1)))
1567caused a stack overflow instead of the diagnosis of a non-fixed length
1568lookbehind assertion. This bug was discovered by the LLVM fuzzer.
1569
157017. The use of \K in a positive lookbehind assertion in a non-anchored pattern
1571(e.g. /(?<=\Ka)/) could make pcre2grep loop.
1572
157318. There was a similar problem to 17 in pcre2test for global matches, though
1574the code there did catch the loop.
1575
157619. If a greedy quantified \X was preceded by \C in UTF mode (e.g. \C\X*),
1577and a subsequent item in the pattern caused a non-match, backtracking over the
1578repeated \X did not stop, but carried on past the start of the subject, causing
1579reference to random memory and/or a segfault. There were also some other cases
1580where backtracking after \C could crash. This set of bugs was discovered by the
1581LLVM fuzzer.
1582
158320. The function for finding the minimum length of a matching string could take
1584a very long time if mutual recursion was present many times in a pattern, for
1585example, /((?2){73}(?2))((?1))/. A better mutual recursion detection method has
1586been implemented. This infelicity was discovered by the LLVM fuzzer.
1587
158821. Implemented PCRE2_NEVER_BACKSLASH_C.
1589
159022. The feature for string replication in pcre2test could read from freed
1591memory if the replication required a buffer to be extended, and it was not
1592working properly in 16-bit and 32-bit modes. This issue was discovered by a
1593fuzzer: see http://lcamtuf.coredump.cx/afl/.
1594
159523. Added the PCRE2_ALT_CIRCUMFLEX option.
1596
159724. Adjust the treatment of \8 and \9 to be the same as the current Perl
1598behaviour.
1599
160025. Static linking against the PCRE2 library using the pkg-config module was
1601failing on missing pthread symbols.
1602
160326. If a group that contained a recursive back reference also contained a
1604forward reference subroutine call followed by a non-forward-reference
1605subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
1606compile correct code, leading to undefined behaviour or an internally detected
1607error. This bug was discovered by the LLVM fuzzer.
1608
160927. Quantification of certain items (e.g. atomic back references) could cause
1610incorrect code to be compiled when recursive forward references were involved.
1611For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/. This bug was
1612discovered by the LLVM fuzzer.
1613
161428. A repeated conditional group whose condition was a reference by name caused
1615a buffer overflow if there was more than one group with the given name. This
1616bug was discovered by the LLVM fuzzer.
1617
161829. A recursive back reference by name within a group that had the same name as
1619another group caused a buffer overflow. For example: /(?J)(?'d'(?'d'\g{d}))/.
1620This bug was discovered by the LLVM fuzzer.
1621
162230. A forward reference by name to a group whose number is the same as the
1623current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused a
1624buffer overflow at compile time. This bug was discovered by the LLVM fuzzer.
1625
162631. Fix -fsanitize=undefined warnings for left shifts of 1 by 31 (it treats 1
1627as an int; fixed by writing it as 1u).
1628
162932. Fix pcre2grep compile when -std=c99 is used with gcc, though it still gives
1630a warning for "fileno" unless -std=gnu99 us used.
1631
163233. A lookbehind assertion within a set of mutually recursive subpatterns could
1633provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
1634
163534. Give an error for an empty subpattern name such as (?'').
1636
163735. Make pcre2test give an error if a pattern that follows #forbud_utf contains
1638\P, \p, or \X.
1639
164036. The way named subpatterns are handled has been refactored. There is now a
1641pre-pass over the regex which does nothing other than identify named
1642subpatterns and count the total captures. This means that information about
1643named patterns is known before the rest of the compile. In particular, it means
1644that forward references can be checked as they are encountered. Previously, the
1645code for handling forward references was contorted and led to several errors in
1646computing the memory requirements for some patterns, leading to buffer
1647overflows.
1648
164937. There was no check for integer overflow in subroutine calls such as (?123).
1650
165138. The table entry for \l in EBCDIC environments was incorrect, leading to its
1652being treated as a literal 'l' instead of causing an error.
1653
165439. If a non-capturing group containing a conditional group that could match
1655an empty string was repeated, it was not identified as matching an empty string
1656itself. For example: /^(?:(?(1)x|)+)+$()/.
1657
165840. In an EBCDIC environment, pcretest was mishandling the escape sequences
1659\a and \e in test subject lines.
1660
166141. In an EBCDIC environment, \a in a pattern was converted to the ASCII
1662instead of the EBCDIC value.
1663
166442. The handling of \c in an EBCDIC environment has been revised so that it is
1665now compatible with the specification in Perl's perlebcdic page.
1666
166743. Single character repetition in JIT has been improved. 20-30% speedup
1668was achieved on certain patterns.
1669
167044. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
1671ASCII/Unicode. This has now been added to the list of characters that are
1672recognized as white space in EBCDIC.
1673
167445. When PCRE2 was compiled without Unicode support, the use of \p and \P gave
1675an error (correctly) when used outside a class, but did not give an error
1676within a class.
1677
167846. \h within a class was incorrectly compiled in EBCDIC environments.
1679
168047. JIT should return with error when the compiled pattern requires
1681more stack space than the maximum.
1682
168348. Fixed a memory leak in pcre2grep when a locale is set.
1684
1685
1686Version 10.10 06-March-2015
1687---------------------------
1688
16891. When a pattern is compiled, it remembers the highest back reference so that
1690when matching, if the ovector is too small, extra memory can be obtained to
1691use instead. A conditional subpattern whose condition is a check on a capture
1692having happened, such as, for example in the pattern /^(?:(a)|b)(?(1)A|B)/, is
1693another kind of back reference, but it was not setting the highest
1694backreference number. This mattered only if pcre2_match() was called with an
1695ovector that was too small to hold the capture, and there was no other kind of
1696back reference (a situation which is probably quite rare). The effect of the
1697bug was that the condition was always treated as FALSE when the capture could
1698not be consulted, leading to a incorrect behaviour by pcre2_match(). This bug
1699has been fixed.
1700
17012. Functions for serialization and deserialization of sets of compiled patterns
1702have been added.
1703
17043. The value that is returned by PCRE2_INFO_SIZE has been corrected to remove
1705excess code units at the end of the data block that may occasionally occur if
1706the code for calculating the size over-estimates. This change stops the
1707serialization code copying uninitialized data, to which valgrind objects. The
1708documentation of PCRE2_INFO_SIZE was incorrect in stating that the size did not
1709include the general overhead. This has been corrected.
1710
17114. All code units in every slot in the table of group names are now set, again
1712in order to avoid accessing uninitialized data when serializing.
1713
17145. The (*NO_JIT) feature is implemented.
1715
17166. If a bug that caused pcre2_compile() to use more memory than allocated was
1717triggered when using valgrind, the code in (3) above passed a stupidly large
1718value to valgrind. This caused a crash instead of an "internal error" return.
1719
17207. A reference to a duplicated named group (either a back reference or a test
1721for being set in a conditional) that occurred in a part of the pattern where
1722PCRE2_DUPNAMES was not set caused the amount of memory needed for the pattern
1723to be incorrectly calculated, leading to overwriting.
1724
17258. A mutually recursive set of back references such as (\2)(\1) caused a
1726segfault at compile time (while trying to find the minimum matching length).
1727The infinite loop is now broken (with the minimum length unset, that is, zero).
1728
17299. If an assertion that was used as a condition was quantified with a minimum
1730of zero, matching went wrong. In particular, if the whole group had unlimited
1731repetition and could match an empty string, a segfault was likely. The pattern
1732(?(?=0)?)+ is an example that caused this. Perl allows assertions to be
1733quantified, but not if they are being used as conditions, so the above pattern
1734is faulted by Perl. PCRE2 has now been changed so that it also rejects such
1735patterns.
1736
173710. The error message for an invalid quantifier has been changed from "nothing
1738to repeat" to "quantifier does not follow a repeatable item".
1739
174011. If a bad UTF string is compiled with NO_UTF_CHECK, it may succeed, but
1741scanning the compiled pattern in subsequent auto-possessification can get out
1742of step and lead to an unknown opcode. Previously this could have caused an
1743infinite loop. Now it generates an "internal error" error. This is a tidyup,
1744not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an
1745undefined outcome.
1746
174712. A UTF pattern containing a "not" match of a non-ASCII character and a
1748subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.
1749
175013. The locale test (RunTest 3) has been upgraded. It now checks that a locale
1751that is found in the output of "locale -a" can actually be set by pcre2test
1752before it is accepted. Previously, in an environment where a locale was listed
1753but would not set (an example does exist), the test would "pass" without
1754actually doing anything. Also the fr_CA locale has been added to the list of
1755locales that can be used.
1756
175714. Fixed a bug in pcre2_substitute(). If a replacement string ended in a
1758capturing group number without parentheses, the last character was incorrectly
1759literally included at the end of the replacement string.
1760
176115. A possessive capturing group such as (a)*+ with a minimum repeat of zero
1762failed to allow the zero-repeat case if pcre2_match() was called with an
1763ovector too small to capture the group.
1764
176516. Improved error message in pcre2test when setting the stack size (-S) fails.
1766
176717. Fixed two bugs in CMakeLists.txt: (1) Some lines had got lost in the
1768transfer from PCRE1, meaning that CMake configuration failed if "build tests"
1769was selected. (2) The file src/pcre2_serialize.c had not been added to the list
1770of PCRE2 sources, which caused a failure to build pcre2test.
1771
177218. Fixed typo in pcre2_serialize.c (DECL instead of DEFN) that causes problems
1773only on Windows.
1774
177519. Use binary input when reading back saved serialized patterns in pcre2test.
1776
177720. Added RunTest.bat for running the tests under Windows.
1778
177921. "make distclean" was not removing config.h, a file that may be created for
1780use with CMake.
1781
178222. A pattern such as "((?2){0,1999}())?", which has a group containing a
1783forward reference repeated a large (but limited) number of times within a
1784repeated outer group that has a zero minimum quantifier, caused incorrect code
1785to be compiled, leading to the error "internal error: previously-checked
1786referenced subpattern not found" when an incorrect memory address was read.
1787This bug was reported as "heap overflow", discovered by Kai Lu of Fortinet's
1788FortiGuard Labs. (Added 24-March-2015: CVE-2015-2325 was given to this.)
1789
179023. A pattern such as "((?+1)(\1))/" containing a forward reference subroutine
1791call within a group that also contained a recursive back reference caused
1792incorrect code to be compiled. This bug was reported as "heap overflow",
1793discovered by Kai Lu of Fortinet's FortiGuard Labs. (Added 24-March-2015:
1794CVE-2015-2326 was given to this.)
1795
179624. Computing the size of the JIT read-only data in advance has been a source
1797of various issues, and new ones are still appear unfortunately. To fix
1798existing and future issues, size computation is eliminated from the code,
1799and replaced by on-demand memory allocation.
1800
180125. A pattern such as /(?i)[A-`]/, where characters in the other case are
1802adjacent to the end of the range, and the range contained characters with more
1803than one other case, caused incorrect behaviour when compiled in UTF mode. In
1804that example, the range a-j was left out of the class.
1805
1806
1807Version 10.00 05-January-2015
1808-----------------------------
1809
1810Version 10.00 is the first release of PCRE2, a revised API for the PCRE
1811library. Changes prior to 10.00 are logged in the ChangeLog file for the old
1812API, up to item 20 for release 8.36.
1813
1814The code of the library was heavily revised as part of the new API
1815implementation. Details of each and every modification were not individually
1816logged. In addition to the API changes, the following changes were made. They
1817are either new functionality, or bug fixes and other noticeable changes of
1818behaviour that were implemented after the code had been forked.
1819
18201. Including Unicode support at build time is now enabled by default, but it
1821can optionally be disabled. It is not enabled by default at run time (no
1822change).
1823
18242. The test program, now called pcre2test, was re-specified and almost
1825completely re-written. Its input is not compatible with input for pcretest.
1826
18273. Patterns may start with (*NOTEMPTY) or (*NOTEMPTY_ATSTART) to set the
1828PCRE2_NOTEMPTY or PCRE2_NOTEMPTY_ATSTART options for every subject line that is
1829matched by that pattern.
1830
18314. For the benefit of those who use PCRE2 via some other application, that is,
1832not writing the function calls themselves, it is possible to check the PCRE2
1833version by matching a pattern such as /(?(VERSION>=10)yes|no)/ against a
1834string such as "yesno".
1835
18365. There are case-equivalent Unicode characters whose encodings use different
1837numbers of code units in UTF-8. U+023A and U+2C65 are one example. (It is
1838theoretically possible for this to happen in UTF-16 too.) If a backreference to
1839a group containing one of these characters was greedily repeated, and during
1840the match a backtrack occurred, the subject might be backtracked by the wrong
1841number of code units. For example, if /^(\x{23a})\1*(.)/ is matched caselessly
1842(and in UTF-8 mode) against "\x{23a}\x{2c65}\x{2c65}\x{2c65}", group 2 should
1843capture the final character, which is the three bytes E2, B1, and A5 in UTF-8.
1844Incorrect backtracking meant that group 2 captured only the last two bytes.
1845This bug has been fixed; the new code is slower, but it is used only when the
1846strings matched by the repetition are not all the same length.
1847
18486. A pattern such as /()a/ was not setting the "first character must be 'a'"
1849information. This applied to any pattern with a group that matched no
1850characters, for example: /(?:(?=.)|(?<!x))a/.
1851
18527. When an (*ACCEPT) is triggered inside capturing parentheses, it arranges for
1853those parentheses to be closed with whatever has been captured so far. However,
1854it was failing to mark any other groups between the highest capture so far and
1855the currrent group as "unset". Thus, the ovector for those groups contained
1856whatever was previously there. An example is the pattern /(x)|((*ACCEPT))/ when
1857matched against "abcd".
1858
18598. The pcre2_substitute() function has been implemented.
1860
18619. If an assertion used as a condition was quantified with a minimum of zero
1862(an odd thing to do, but it happened), SIGSEGV or other misbehaviour could
1863occur.
1864
186510. The PCRE2_NO_DOTSTAR_ANCHOR option has been implemented.
1866
1867****