Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: cbarratt [...] users.sourceforge.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.30
Fixed in: (no value)



Subject: Fails on unseekable file handle after desiredCompressionLevel()
Archive::Zip 1.30 fails writing to an unseekable file handle after calling desiredCompressionLevel(). 1.23 works fine. Tested with perl 5.8.8 and 5.10.0. Here is a test program, test.pl: #!/usr/bin/perl use strict; use Archive::Zip; use IO::Handle; my $fh = new IO::Handle; $fh->fdopen(fileno(STDOUT), "w"); my $zip = Archive::Zip->new(); my $fileMember = $zip->addFile("test.pl"); $fileMember->desiredCompressionLevel(5); $zip->writeToFileHandle($fh, 0); Running it as: ./test.pl > test.zip fails with the error: Can't locate object method "tell" via package "IO::Handle" at /usr/lib/perl5/vendor_perl/5.8.8/Archive/Zip/Member.pm line 746. The bug is that Archive::Zip::Member->bitFlag() overwrites the flags when it is called, even with no arguments. In particular, _writeToFileHandle() calls: $self->hasDataDescriptor(1) when the output is not seekable, which sets GPBF_HAS_DATA_DESCRIPTOR_MASK in $self->{'bitFlag'}. Just after that, _writeToFileHandle() calls _writeLocalFileHeader(), which in turn calls $self->bitFlag(). That overwrites the GPBF_HAS_DATA_DESCRIPTOR_MASK bit, and then _writeToFileHandle() calls _refreshLocalFileHeader() instead of _writeDataDescriptor() because that bit was cleared. A patch to fix it is attached, although I don't know if it is correct. The code that sets bitFlag is only executed when bitFlag is called with an argument. The reason I don't think it is correct is I don't see where bitFlag(0) is called to do this initialization. Perhaps this code should move to desiredCompressionLevel()? Craig
Subject: bitFlag_patch_1_30
Download bitFlag_patch_1_30
application/octet-stream 1.5k

Message body not shown because it is not plain text.

From: dma_k [...] mail.ru
I vote for this bug. This bug has impact on BackupPC software: https://sourceforge.net/mailarchive/forum.php?thread_name=201005111944.08468.tyler%40tolaris.com&forum_name=backuppc-users https://sourceforge.net/mailarchive/forum.php?thread_name=sig.17267b10cc.4BCE103B.8040200%40drdos.info&forum_name=backuppc-users Суб Фев 20 20:05:06 2010, CBARRATT писал: Show quoted text
> Archive::Zip 1.30 fails writing to an unseekable file handle after > calling desiredCompressionLevel(). 1.23 works fine. Tested with perl > 5.8.8 and 5.10.0.
From: BitCard [...] ResonatorSoft.org
I'm having similar problems with this issue: IO error: seeking to rewrite local header : Illegal seek at /usr/local/share/perl/5.10.0/Archive/Zip/Member.pm line 747 Archive::Zip::Member::_refreshLocalFileHeader('Archive::Zip::StringMember=HASH(0x95fda00)', 'STDOUT') called at /usr/local/share/perl/5.10.0/Archive/Zip/Member.pm line 1034 Archive::Zip::Member::_writeToFileHandle('Archive::Zip::StringMember=HASH(0x95fda00)', 'STDOUT', 0, 0) called at /usr/local/share/perl/5.10.0/Archive/Zip/Archive.pm line 402 Archive::Zip::Archive::writeToFileHandle('Archive::Zip::Archive=HASH(0x92fddf0)', 'STDOUT', 0) called at ziptest.pl line 17 The bitFlag sub seems to be the issue, though, it never has any parameters, so the proposed patch would just break compression level settings. The main problem is that, as a bitmap, it should NEVER be set with "bitFlag = ###". The bitFlag needs to be set using bitwise math. The desiredCompressionMethod sub does it right, but not the bitFlag one. I have a patch that should properly fix the problem. Please get this one in production, since it impacts a lot of web scripts that send ZIPs on-the-fly.
Subject: Archive-Zip-1.30-bitFlag-patch.txt
*** /usr/local/share/perl/5.10.0/Archive/Zip/Member.pm 2009-06-30 07:51:10.000000000 -0400 --- Member.pm 2011-05-02 15:10:24.000000000 -0400 *************** *** 159,171 **** # Set General Purpose Bit Flags according to the desiredCompressionLevel setting if ( $self->desiredCompressionLevel == 1 || $self->desiredCompressionLevel == 2 ) { ! $self->{'bitFlag'} = DEFLATING_COMPRESSION_FAST; } elsif ( $self->desiredCompressionLevel == 3 || $self->desiredCompressionLevel == 4 || $self->desiredCompressionLevel == 5 || $self->desiredCompressionLevel == 6 || $self->desiredCompressionLevel == 7 ) { ! $self->{'bitFlag'} = DEFLATING_COMPRESSION_NORMAL; } elsif ( $self->desiredCompressionLevel == 8 || $self->desiredCompressionLevel == 9 ) { ! $self->{'bitFlag'} = DEFLATING_COMPRESSION_MAXIMUM; } $self->{'bitFlag'}; } --- 159,171 ---- # Set General Purpose Bit Flags according to the desiredCompressionLevel setting if ( $self->desiredCompressionLevel == 1 || $self->desiredCompressionLevel == 2 ) { ! $self->{'bitFlag'} |= DEFLATING_COMPRESSION_FAST; } elsif ( $self->desiredCompressionLevel == 3 || $self->desiredCompressionLevel == 4 || $self->desiredCompressionLevel == 5 || $self->desiredCompressionLevel == 6 || $self->desiredCompressionLevel == 7 ) { ! $self->{'bitFlag'} |= DEFLATING_COMPRESSION_NORMAL; } elsif ( $self->desiredCompressionLevel == 8 || $self->desiredCompressionLevel == 9 ) { ! $self->{'bitFlag'} |= DEFLATING_COMPRESSION_MAXIMUM; } $self->{'bitFlag'}; }
Can we patch this please?
From: tim [...] seoss.co.uk
FYI, this is still blocking https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618780 "Create corrupt zip files with Backuppc" - the bug was created in Mar 2011. The regression in libarchive-zip-perl which caused the bug in Backuppc occurred between Archive::Zip v1.18 and v1.30. It is still present in v1.39.
From: jeff.raber [...] gmail.com
Fedora have been using this patch[1] since March 2012. It seem to have resolved the issue, and does not seem to have cause any new problem 1:http://pkgs.fedoraproject.org/cgit/perl-Archive-Zip.git/tree/Archive-Zip-cpan-rt-54827.patch
Patch applied in 1.49