#536495 perl: missing / incorrect overflow check when indexing arrays

Package:
perl
Source:
perl
Description:
Larry Wall's Practical Extraction and Report Language
Submitter:
Sebastian Harl
Date:
2020-11-15 00:21:08 UTC
Severity:
normal
Tags:
#536495#5
Date:
2009-07-10 12:52:00 UTC
From:
To:
Hi,

Perl does not handle large array indexes correctly:

 % perl -e '$a[23] = "foo\n"; print $a[1 + ~1];'
 foo

FTR: That '1 + ~1' produces expected results when not used as an array
index:

 % perl -e 'print 1 + ~1, $/;'
 4294967295

While I do not expect Perl to handle arbitrary large array indexes, it
would be very nice to get a warning in that case instead of a random
(well, it actually seems to be always the last) element of the array.

Cheers,
Sebastian

#536495#10
Date:
2009-07-10 13:00:58 UTC
From:
To:
forwarded 536495 http://rt.perl.org/rt3//Public/Bug/Display.html?id=67424
tags 536495 + upstream
found 536495 5.10.0-19
thanks

Hi,

This bug has also been reported upstream as ticket #67424. Also,
upstream (Nicholas and vincent in #p5p) has been notified in IRC.

Cheers,
Sebastian