GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Writing a small file into a ZipFile while forcing zip64 extensions results in an incorrect zip file · Issue #103861 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Writing a small file into a ZipFile while forcing zip64 extensions results in an incorrect zip file#103861
Copy link
Labels
3.11only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@pR0Ps
pR0Ps
opened on Apr 25, 2023
Issue body actions

Bug report

When forcing a small file to be added to a zipfile.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:

import zipfile

with zipfile.ZipFile("out.zip", mode="w", allowZip64=True) as zf:
    with zf.open("text.txt", mode="w", force_zip64=True) as zi:
        zi.write(b"some data")

Using zipdetails 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 be 0x2D (zipfile.ZIP64_VERSION) and the Compressed/Uncompressed Lengths should both be 0xFFFFFFFF 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

  • gh-103861: Fix Zip64 extensions not being properly applied in some cases #103863
  • [3.11] gh-103861: Fix Zip64 extensions not being properly applied in some cases (GH-103863) #104534

Activity

  1. pR0Ps
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 25, 2023
  2. pR0Ps
    added 5 commits that reference this issue on Apr 26, 2023

    Fix Zip64 extensions not being properly applied in some cases

    This issue will close once commit 1bdd946 is merged into the 'main' branch.
    1bdd946

    Fix Zip64 extensions not being properly applied in some cases

    This issue will close once commit 0551a0e is merged into the 'main' branch.
    0551a0e

    Fix Zip64 extensions not being properly applied in some cases

    This issue will close once commit bd02290 is merged into the 'main' branch.
    bd02290

    Fix Zip64 extensions not being properly applied in some cases

    This issue will close once commit 03a58a6 is merged into the 'main' branch.
    03a58a6

    Fix Zip64 extensions not being properly applied in some cases

    This issue will close once commit c42700d is merged into the 'main' branch.
    c42700d
  3. arhadthedev
    added this to Zipfile issues 📦on Apr 29, 2023
  4. gpshead
    closed this as completedin 798bcaaon May 16, 2023
  5. github-project-automation
    moved this to Done in Zipfile issues 📦on May 16, 2023
  6. gpshead
    added a commit that references this issue on May 16, 2023

    [3.11] pythongh-103861: Fix Zip64 extensions not being properly appli…

    f09ad48
  7. gpshead
    added
    3.11only security fixesonly security fixes
    on May 16, 2023
  8. carljm
    added a commit that references this issue on May 16, 2023

    Merge branch 'main' into supermon

    a6dd626
  9. gpshead
    added a commit that references this issue on May 17, 2023

    [3.11] gh-103861: Fix Zip64 extensions not being properly applied in …

    133bf09
  10. pelson
    added a commit that references this issue on Feb 12, 2024

    pythongh-103861: Fix Zip64 extensions not being properly applied in s…

    798bcaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    • Zipfile issues 📦
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.