Skip Menu |
 

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id: 11818
Status: resolved
Priority: 0/
Queue: Archive-Zip

People
Owner: Nobody in particular
Requestors: h.kraenz [...] mdl.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.14
Fixed in: 1.15_01



Subject: extractMember method corrupts archive
Download (untitled) / with headers
text/plain 2.5k
First, I've to say that Archive::Zip is a really nice and extremely use full module - nearly each of my applications uses it. I'm using Archive::Zip on an AIX (AIX aix-ff9 3 4 004434FA4C00) with perl 5.8.0. I know these version both are pretty old (ok: completely out of date and unsopported) but I cannot upgrade any of these because the server is running important production systems :-( I used Archive::Zip 0.11 for a very long time and I wanted to upgrade to 1.x (in order to use the overwrite and addTree methods). But after the upgrade the perl programs that use Archive::Zip did not work at all. I have reduced the error to a small program inserted below. It works fine under Archive::Zip 0.11 but produces the error listed below when I use Arche::Zip 1.14. If I comment out the line $Z1->extractMemberWithoutPaths( "t.pl" , "x.pl" ); everything works fine. Can you give me a hint? Thanks in advance Helge Here's the program: === SNIP === #!/usr/bin/perl use strict; use lib '/projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib'; use Archive::Zip 0.11 qw( :ERROR_CODES :CONSTANTS ); my $Z0 = Archive::Zip->new(); $Z0->addFile( "t.pl" ); $Z0->writeToFileNamed( "test.zip" ); my $Z1 = Archive::Zip->new(); $Z1->read( "test.zip" ); $Z1->extractMemberWithoutPaths( "t.pl" , "x.pl" ); $Z1->writeToFileNamed( "test2.zip" ); === SNIP === And here's the output: === SNIP === IO error: reading data : Archive::Zip::ZipFileMember::_readRawChunk('Archive::Zip::ZipFileMember=HASH(0x203dcfb4)','SCALAR(0x203e2b04)',83) called at /projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib/Archive/Zip.pm line 2048 Archive::Zip::Member::readChunk('Archive::Zip::ZipFileMember=HASH(0x203dcfb4)',32768) called at /projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib/Archive/Zip.pm line 2344 Archive::Zip::Member::_writeData('Archive::Zip::ZipFileMember=HASH(0x203dcfb4)','IO::File=GLOB(0x203b7df8)') called at /projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib/Archive/Zip.pm line 2313 Archive::Zip::Member::_writeToFileHandle('Archive::Zip::ZipFileMember=HASH(0x203dcfb4)','IO::File=GLOB(0x203b7df8)',1,0) called at /projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib/Archive/Zip.pm line 778 Archive::Zip::Archive::writeToFileHandle('Archive::Zip::Archive=HASH(0x2005df74)','IO::File=GLOB(0x203b7df8)',1) called at /projects/patent/d03/bin/temp/az/Archive-Zip-1.14/blib/lib/Archive/Zip.pm line 756 Archive::Zip::Archive::writeToFileNamed('Archive::Zip::Archive=HASH(0x2005df74)','test2.zip') called at ./t.pl line 14
RT-Send-CC: Steve Peters <steve.peters [...] gmail.com>,steve [...] fisharerojo.org
Download (untitled) / with headers
text/plain 276b
The problem seems to be that extractMemberWithoutPaths() (probably also extractMember()) clobbers compressedSize, which had been read correctly upon the initial archive read. The attached file shows that resetting it to its original value will make the subsequent write work.
Download test11818.pl
text/x-perl 1k
#!/usr/bin/perl use strict; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); unlink('test.zip'); my $Z0 = Archive::Zip->new(); my $member0 = $Z0->addFile($0) || die 'no member added'; $Z0->writeToFileNamed("test.zip") && die "test.zip write error: $!"; undef($Z0); undef($member0); unlink('test2.zip'); unlink('t.pl'); my $Z1 = Archive::Zip->new(); $Z1->read("test.zip") && die "test.zip read error: $!"; my $originalMember = $Z1->memberNamed($0); die "no member named $0" unless $originalMember; my $originalCompressedSize = $originalMember->compressedSize(); # Problem is that extractMemberWithoutPaths() (probably also extractMember()) clobbers compressedSize $Z1->extractMemberWithoutPaths( $0, "t.pl" ) && die "no extract of member from Z1"; # restoring compressed size makes it work: printf("Original compressed size: %d after extract: %d\n", $originalCompressedSize, $originalMember->compressedSize()); $originalMember->{'compressedSize'} = $originalCompressedSize; $Z1->writeToFileNamed("test2.zip") && die "test2.zip write error: $!";
Subject: attached file.
RT-Send-CC: Steve Peters <steve.peters [...] gmail.com>,steve [...] fisharerojo.org
attachment didn't work... #!/usr/bin/perl use strict; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); unlink('test.zip'); my $Z0 = Archive::Zip->new(); my $member0 = $Z0->addFile($0) || die 'no member added'; $Z0->writeToFileNamed("test.zip") && die "test.zip write error: $!"; undef($Z0); undef($member0); unlink('test2.zip'); unlink('t.pl'); my $Z1 = Archive::Zip->new(); $Z1->read("test.zip") && die "test.zip read error: $!"; my $originalMember = $Z1->memberNamed($0); die "no member named $0" unless $originalMember; my $originalCompressedSize = $originalMember->compressedSize(); # Problem is that extractMemberWithoutPaths() (probably also extractMember()) clobbers compressedSize $Z1->extractMemberWithoutPaths( $0, "t.pl" ) && die "no extract of member from Z1"; # restoring compressed size makes it work: printf("Original compressed size: %d after extract: %d\n", $originalCompressedSize, $originalMember->compressedSize()); $originalMember->{'compressedSize'} = $originalCompressedSize; $Z1->writeToFileNamed("test2.zip") && die "test2.zip write error: $!";
Download (untitled) / with headers
text/plain 1.2k
[NEDKONZ - Wed Mar 9 10:23:50 2005]: Show quoted text
> attachment didn't work... > > #!/usr/bin/perl > > use strict; > use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); > > unlink('test.zip'); > my $Z0 = Archive::Zip->new(); > my $member0 = $Z0->addFile($0) || die 'no member added'; > $Z0->writeToFileNamed("test.zip") && die "test.zip write error: $!"; > undef($Z0); > undef($member0); > > unlink('test2.zip'); > unlink('t.pl'); > my $Z1 = Archive::Zip->new(); > $Z1->read("test.zip") && die "test.zip read error: $!"; > my $originalMember = $Z1->memberNamed($0); > die "no member named $0" unless $originalMember; > my $originalCompressedSize = $originalMember->compressedSize(); > > # Problem is that extractMemberWithoutPaths() (probably also > extractMember()) clobbers compressedSize > $Z1->extractMemberWithoutPaths( $0, "t.pl" ) && die "no extract of > member from Z1"; > > # restoring compressed size makes it work: > printf("Original compressed size: %d after extract: %d\n", > $originalCompressedSize, $originalMember->compressedSize()); > $originalMember->{'compressedSize'} = $originalCompressedSize; > > $Z1->writeToFileNamed("test2.zip") && die "test2.zip write error: $!";
This problem has been added to the TODOs and should be fixed in the next release.
This problem is fixed in Archive::Zip 1.15_01. Thanks for the report.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.