Skip to content

archive/zip: non-standard handling of conflicts between central directory and local file headers #76074

@neild

Description

@neild

This is related to #40354, but a bit different.

Construct a zip file containing a file where:

  • The central directory record contains a compressed file size of S1.
  • The local file header gives a contains a compressed file size of 0.
  • Bit 3 of the local file header's flag bit is 0.

Info-Zip's UnZip will prefer the local file header (extracting a file of size 0), but archive/zip will prefer the central directory record (extracting S1 compressed bytes).

PKWARE's spec says about bit 3 of the local file header flags:

         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.)

I haven't attempted to check what other implementations do. (Actually, I'm not sure if bit 3 is relevant or not here, but the spec seems to indicate that it is.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions