Subject: | Creation of non-standard streamed zip file |
When digging around #92205 I spotted that Archive::Zip created a non-standard local header when it process a zip file that already uses streaming. Here is the relevant part from appnote.txt that discusses streaming (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT)
4.4.4 general purpose bit flag: (2 bytes)
. . .
Bit 3: If this bit is set, the fields crc-32, compressed
size and uncompressed size are set to zero in the
local header. The correct values are put in the
data descriptor immediately following the compressed
data. (Note: PKZIP version 2.04g for DOS only
recognizes this bit for method 8 compression, newer
versions of PKZIP recognize this bit for any
compression method.
The enclosed file, abc.zip, contains a single member "fred" that has been streamed. This is how I created it:
$ perl -MIO::Compress::Zip=zip -e 'zip \"abc" => "abc.zip", Name => "fred", Stream => 1, Method => 8'
Here is a dump of the local headers section of the zip file
$ zipdetails abc.zip
0000 LOCAL HEADER #1 04034B50
0004 Extract Zip Spec 14 '2.0'
0005 Extract OS 00 'MS-DOS'
0006 General Purpose Flag 0008
[Bits 1-2] 0 'Normal Compression'
[Bit 3] 1 'Streamed'
0008 Compression Method 0008 'Deflated'
000A Last Mod Time 4596BBBD 'Mon Dec 22 23:29:58 2014'
000E CRC 00000000
0012 Compressed Length 00000000
0016 Uncompressed Length 00000000
001A Filename Length 0004
001C Extra Length 0000
001E Filename 'fred'
0022 PAYLOAD KLJ..
0027 STREAMING DATA HEADER 08074B50
002B CRC 352441C2
002F Compressed Length 00000005
0033 Uncompressed Length 00000003
Key points are the presence of the Streamed bit, and that CRC, Compressed length & Uncompressed length are all zero in the local header, but populated in the Data Header.
I then got Archive::Zip to process the streamed zip file as follows
$ perl -MArchive::Zip -e 'my $z = Archive::Zip->new; $z->read(shift); $z->writeToFileNamed("out.zip");' abc.zip
Here are the local headers from the new zip file
$ zipdetails out.zip
0000 LOCAL HEADER #1 04034B50
0004 Extract Zip Spec 14 '2.0'
0005 Extract OS 00 'MS-DOS'
0006 General Purpose Flag 0008
[Bits 1-2] 0 'Normal Compression'
[Bit 3] 1 'Streamed'
0008 Compression Method 0008 'Deflated'
000A Last Mod Time 4596BBBD 'Mon Dec 22 23:29:58 2014'
000E CRC 352441C2
0012 Compressed Length 00000005
0016 Uncompressed Length 00000003
001A Filename Length 0004
001C Extra Length 0000
001E Filename 'fred'
0022 PAYLOAD KLJ..
0027 STREAMING DATA HEADER 08074B50
002B CRC 352441C2
002F Compressed Length 00000005
0033 Uncompressed Length 00000003
Note the Streaming bit is set but the values for CRC, Compressed length & Uncompressed length are all populated in the Local Header with values that match the Streaming Data Header.
Subject: | abc.zip |
Message body not shown because it is not plain text.