On Perl 5.10, I get an assertion when trying to encrypt a variable
that's a hash key. The crash does not occur on Perl 5.8.5.
Perl v5.10.0, Crypt::DES version 2.05.
There's a simple test case attached.
Stack trace:
Assertion he->shared_he_he.hent_hek == hek failed: file "hv.c", line
2257 at /tmp/busted.pl line 15.
*** glibc detected *** /opt/airwave/bin/perl: free(): invalid next size
(fast): 0x09863690 ***
======= Backtrace: =========
/lib/libc.so.6[0x3e6aa6]
/lib/libc.so.6(cfree+0x90)[0x3e9fc0]
/opt/airwave/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/libperl.so(Perl_safesysfree+0xff)[0x5fdb7f]
/opt/airwave/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/libperl.so(perl_free+0x7c)[0x6216fc]
/opt/airwave/bin/perl(main+0xe8)[0x8048ac8]
/lib/libc.so.6(__libc_start_main+0xdc)[0x395dec]
/opt/airwave/bin/perl[0x8048951]
======= Memory map: ========
00110000-0011f000 r-xp 00000000 fd:00 9571951 /lib/libresolv-2.5.so
0011f000-00120000 r--p 0000e000 fd:00 9571951 /lib/libresolv-2.5.so
00120000-00121000 rw-p 0000f000 fd:00 9571951 /lib/libresolv-2.5.so
00121000-00123000 rw-p 00121000 00:00 0
00123000-00136000 r-xp 00000000 fd:00 9568327 /lib/libnsl-2.5.so
00136000-00137000 r--p 00012000 fd:00 9568327 /lib/libnsl-2.5.so
00137000-00138000 rw-p 00013000 fd:00 9568327 /lib/libnsl-2.5.so
00138000-0013a000 rw-p 00138000 00:00 0
0013a000-0013f000 r-xp 00000000 fd:00 9571952 /lib/libcrypt-2.5.so
0013f000-00140000 r--p 00004000 fd:00 9571952 /lib/libcrypt-2.5.so
00140000-00141000 rw-p 00005000 fd:00 9571952 /lib/libcrypt-2.5.so
00141000-00168000 rw-p 00141000 00:00 0
00168000-0016a000 r-xp 00000000 fd:00 9571953 /lib/libutil-2.5.so
0016a000-0016b000 r--p 00001000 fd:00 9571953 /lib/libutil-2.5.so
0016b000-0016c000 rw-p 00002000 fd:00 9571953 /lib/libutil-2.5.so
0016c000-0017f000 r-xp 00000000 fd:00 9568427 /lib/libpthread-2.5.so
0017f000-00180000 r--p 00012000 fd:00 9568427 /lib/libpthread-2.5.so
00180000-00181000 rw-p 00013000 fd:00 9568427 /lib/libpthread-2.5.so
00181000-00183000 rw-p 00181000 00:00 0
00183000-00187000 r-xp 00000000 fd:00 7702257
/opt/airwave/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/auto/Crypt/DES/DES.so
00187000-00189000 rw-p 00003000 fd:00 7702257
/opt/airwave/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/auto/Crypt/DES/DES.so
00189000-00194000 r-xp 00000000 fd:00 9568310
/lib/libgcc_s-4.1.2-20070626.so.1
00194000-00195000 rw-p 0000a000 fd:00 9568310
/lib/libgcc_s-4.1.2-20070626.so.1
00363000-0037c000 r-xp 00000000 fd:00 9568409 /lib/ld-2.5.so
0037c000-0037d000 r--p 00019000 fd:00 9568409 /lib/ld-2.5.so
0037d000-0037e000 rw-p 0001a000 fd:00 9568409 /lib/ld-2.5.so
00380000-004ba000 r-xp 00000000 fd:00 9568438 /lib/libc-2.5.so
004ba000-004bc000 r--p 0013a000 fd:00 9568438 /lib/libc-2.5.so
004bc000-004bd000 rw-p 0013c000 fd:00 9568438 /lib/libc-2.5.so
004bd000-004c0000 rw-p 004bd000 00:00 0
004c2000-004c4000 r-xp 00000000 fd:00 9571950 /lib/libdl-2.5.so
004c4000-004c5000 r--p 00001000 fd:00 9571950 /lib/libdl-2.5.so
004c5000-004c6000 rw-p 00002000 fd:00 9571950 /lib/libdl-2.5.so
004c8000-004ed000 r-xp 00000000 fd:00 9571949 /lib/libm-2.5.so
004ed000-004ee000 r--p 00024000 fd:00 9571949 /lib/libm-2.5.so
004ee000-004ef000 rw-p 00025000 fd:00 9571949 /lib/libm-2.5.so
00556000-0079f000 r-xp 00000000 fd:00 7701896
/opt/airwave/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/libperl.so
0079f000-007a4000 rw-p 00249000 fd:00 7701896
/opt/airwave/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/libperl.so
00a14000-00a15000 r-xp 00a14000 00:00 0 [vdso]
08048000-08049000 r-xp 00000000 fd:00 7471815 /opt/airwave/bin/perl
08049000-0804a000 rw-p 00000000 fd:00 7471815 /opt/airwave/bin/perl
0984e000-098d1000 rw-p 0984e000 00:00 0
b7c00000-b7c21000 rw-p b7c00000 00:00 0
b7c21000-b7d00000 ---p b7c21000 00:00 0
b7db8000-b7db9000 r--p 01934000 fd:00 5445987
/usr/lib/locale/locale-archive
b7db9000-b7dbf000 r--p 018bf000 fd:00 5445987
/usr/lib/locale/locale-archive
b7dbf000-b7df3000 r--p 01887000 fd:00 5445987
/usr/lib/locale/locale-archive
b7df3000-b7ff3000 r--p 00000000 fd:00 5445987
/usr/lib/locale/locale-archive
b7ff3000-b7ff6000 rw-p b7ff3000 00:00 0
b7ffc000-b7ffd000 rw-p b7ffc000 00:00 0
bfe82000-bfe98000 rw-p bfe82000 00:00 0 [stack]
Subject: | crypt-des-crash.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Crypt::DES;
my $cipher = Crypt::DES->new(pack('H*', '1234567812345678'));
my %hash = (
'12345678' => '12345678',
);
# crashes
my ($k) = keys %hash;
$cipher->encrypt($k);
# works
$cipher->encrypt("$k");
# works
my ($v) = values %hash;
$cipher->encrypt($v);