This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-Dmad: double free or corruption
authorTony Cook <tony@develop-help.com>
Tue, 1 Dec 2009 11:25:39 +0000 (22:25 +1100)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Tue, 1 Dec 2009 12:41:18 +0000 (13:41 +0100)
commit0b3da58dfdc350792109691bb6c07a48109b9e12
tree8ca49111e192c7573512af6530f0acf0496b492b
parent235278186f2c0918cc73f3f4c9470f80eeaf8313
-Dmad: double free or corruption

> If your perl has -Dmad, the following program crashes:
>
> $ bleadperl -we '$x="x" x 257; eval "for $x"'
> *** glibc detected *** bleadperl: double free or corruption (!prev): 0x0000000001dca670 ***

Change 6136c704 changed S_scan_ident from:

   e = d + destlen - 3;

to:

   register char * const e = d + destlen + 3;

where e is used to mark the end of the buffer, this meant that the
various buffer end checks allowed the various buffers supplied
S_scan_ident to overflow.

Attached is a fix, various tests with fencepost checks on different
identifier lengths, and the specific case mentioned in the ticket.

Tony

Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
t/comp/parser.t
toke.c