diff options
author | Karl Williamson <khw@cpan.org> | 2018-12-16 11:54:03 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-12-16 12:08:06 -0700 |
commit | cc27c3b3ef8a22c153554c7756ac1a22daddff28 (patch) | |
tree | a133fb2ce459f260e364aff16492558c506f127e | |
parent | b20a43d74c4dca14f892166850418e52b35ba5a4 (diff) | |
download | perl-cc27c3b3ef8a22c153554c7756ac1a22daddff28.tar.gz |
Correct previous perldelta entry, and add a test
The text of perl5294delta was wrong about a change. This commit changes
that text, and adds an entry to the latest perldelta with the
correction. A test has been added to verify the way things work.
The wrong language led to this blog post, and my comment in it:
https://www.effectiveperlprogramming.com/2018/12/perl-v5-30-lets-you-match-more-with-the-general-quantifier/
-rw-r--r-- | pod/perl5294delta.pod | 9 | ||||
-rw-r--r-- | pod/perldelta.pod | 13 | ||||
-rw-r--r-- | t/re/pat.t | 7 |
3 files changed, 24 insertions, 5 deletions
diff --git a/pod/perl5294delta.pod b/pod/perl5294delta.pod index 95c7e7547e..aae8ea9297 100644 --- a/pod/perl5294delta.pod +++ b/pod/perl5294delta.pod @@ -14,11 +14,12 @@ L<perl5293delta>, which describes differences between 5.29.2 and 5.29.3. =head1 Core Enhancements -=head2 The maximum number of times a pattern can match has been doubled -to 65535 +=head2 The upper limit C<"n"> specifiable in a regular expression +quantifier of the form C<"{m,n}"> has been doubled to 65534 -This means if you specify C<qr/a+/> that there can be anywhere from 1 -through 65535 C<"a">'s in a row, instead of 32267 as previously. +The meaning of an unbounded upper quantifier C<"{m,}"> remains unchanged. +It matches 2**31 - 1 times on most platforms, and more on ones where a C +language short variable is more than 4 bytes long. =head1 Incompatible Changes diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 7509c3ef88..372af385ec 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -12,6 +12,19 @@ release. If you are upgrading from an earlier release such as 5.29.4, first read L<perl5295delta>, which describes differences between 5.29.4 and 5.29.5. +=head1 Core Enhancements + +=head2 The upper limit C<"n"> specifiable in a regular expression +quantifier of the form C<"{m,n}"> has been doubled to 65534 + +The meaning of an unbounded upper quantifier C<"{m,}"> remains unchanged. +It matches 2**31 - 1 times on most platforms, and more on ones where a C +language short variable is more than 4 bytes long. + +The text above is what perl5294delta should have said. Instead it said +"The maximum number of times a pattern can match has been doubled to 65535" +That statement was wrong. Try to forget you ever saw it. + =head1 Security =head2 [CVE-2018-18312] Heap-buffer-overflow write in S_regatom (regcomp.c) diff --git a/t/re/pat.t b/t/re/pat.t index ddd34fbd8d..b9c1e262ca 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -23,7 +23,7 @@ BEGIN { skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader; skip_all_without_unicode_tables(); -plan tests => 850; # Update this when adding/deleting tests. +plan tests => 851; # Update this when adding/deleting tests. run_tests() unless caller; @@ -339,6 +339,11 @@ sub run_tests { like($@, qr/^\QQuantifier in {,} bigger than/, $message); eval "'aaa' =~ /a{1,$::reg_infty_p}/"; like($@, qr/^\QQuantifier in {,} bigger than/, $message); + + # It should be 'a' x 2147483647, but that exhausts memory on + # reasonably sized modern machines + like('a' x $::reg_infty_p, qr/a{1,}/, + "{1,} matches more times than REG_INFTY"); } { |