Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
When forcing a small file to be added to azipfile.Zipfile object with zip64 extensions when it doesn't need it, a Zip64 extra record is added to the resulting file, but the minimum version and filesize information are not updated to reflect this.
An example of this issue in the wild:pR0Ps/zipstream-ng#13
To reproduce:
Create the file:
importzipfilewithzipfile.ZipFile("out.zip",mode="w",allowZip64=True)aszf:withzf.open("text.txt",mode="w",force_zip64=True)aszi:zi.write(b"some data")
Usingzipdetails to parse information from the resulting file (red lines are incorrect):
0000 LOCAL HEADER #1 04034B50-0004 Extract Zip Spec 14 '2.0' 0005 Extract OS 00 'MS-DOS' 0006 General Purpose Flag 0000 0008 Compression Method 0000 'Stored' 000A Last Mod Time 00210000 'Mon Dec 31 19:00:00 1979' 000E CRC D9C2E91E-0012 Compressed Length 00000009-0016 Uncompressed Length 00000009 001A Filename Length 0008 001C Extra Length 0014 001E Filename 'text.txt' 0026 Extra ID #0001 0001 'ZIP64' 0028 Length 0010 002A Uncompressed Size 0000000000000009 0032 Compressed Size 0000000000000009 003A PAYLOAD some data 0043 CENTRAL HEADER #1 02014B50-0047 Created Zip Spec 14 '2.0' 0048 Created OS 03 'Unix'-0049 Extract Zip Spec 14 '2.0' 004A Extract OS 00 'MS-DOS' 004B General Purpose Flag 0000 004D Compression Method 0000 'Stored' 004F Last Mod Time 00210000 'Mon Dec 31 19:00:00 1979' 0053 CRC D9C2E91E 0057 Compressed Length 00000009 005B Uncompressed Length 00000009 005F Filename Length 0008 0061 Extra Length 0000 0063 Comment Length 0000 0065 Disk Start 0000 0067 Int File Attributes 0000 [Bit 0] 0 'Binary Data' 0069 Ext File Attributes 01800000 006D Local Header Offset 00000000 0071 Filename 'text.txt' 0079 END CENTRAL HEADER 06054B50 007D Number of this disk 0000 007F Central Dir Disk no 0000 0081 Entries in this disk 0001 0083 Total Entries 0001 0085 Size of Central Dir 00000036 0089 Offset to Central Dir 00000043 008D Comment Length 0000
In this case, the Extract Zip Spec should be0x2D (zipfile.ZIP64_VERSION) and the Compressed/Uncompressed Lengths should both be0xFFFFFFFF in order to defer to the lengths in the Zip64 record.
Your environment
- CPython versions tested on: 3.12.0
- Operating system and architecture: macOS Mojave (x86)
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done