Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Writing a small file into a ZipFile while forcing zip64 extensions results in an incorrect zip file #103861

Closed
Labels
3.11only security fixestype-bugAn unexpected behavior, bug, or error
@pR0Ps

Description

@pR0Ps

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

No one assigned

    Labels

    3.11only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp