Subject: | IO::Compress::Zip does not store uncompressed size properly |
If I print more than 2**12+7 bytes into zip compressor, then the
resulting zip stream while uncompressing reports bad uncompressed size.
Tested with IO-Compress-2.049 on perl-5.14.2 on x86_64 Linux with threads.
Maybe I cannot work with this module properly, but I cannot see any
mistake. Try following code:
#!/usr/bin/perl
use strict;
use warnings;
use IO::Compress::Zip qw($ZipError);
use IO::Uncompress::Unzip qw($UnzipError);
use Data::Dumper;
my $zip;
my $input_length = 2**12+8;
my $compressor = IO::Compress::Zip->new(\$zip, Zip64 => 1)
or die "Constructing compressor failed: $ZipError\n";
$compressor->print('A' x $input_length);
$compressor->close
or die "Could not finish archive: $ZipError\n";
my $decompressor = IO::Uncompress::Unzip->new(\$zip)
or die "Consctucting decompressor failed: $UnzipError\n";
my $output_length = ${$decompressor->getHeaderInfo}{'UncompressedLength'};
print "Expected length: " . $input_length . "\n";
print STDERR Dumper($output_length) . "\n";
if (ref $output_length) {
$output_length = $output_length->get64bit;
}
print "Reported length: " . $output_length . "\n";
if ($input_length == $output_length) {
exit 0;
} else {
exit 1;
}