Skip to content

Files are arbitrarily restricted to being placed before the central header directory #384

@afranchuk

Description

@afranchuk

Describe the bug
In 4065f05#diff-f5613ff66dd29a0567e4173ff7c04ed28b08eb7384040946dd410698700b87eeR1130-R1132 a check was introduced which prevents file data from starting after the central header directory.

This was extended in https://github.com/zip-rs/zip2/pull/247/files#diff-f5613ff66dd29a0567e4173ff7c04ed28b08eb7384040946dd410698700b87eeR1065-R1069 to also check the file header.

While this may be desirable to catch bad entries in some cases, this is not in accordance with the zip spec (I think?), and in particular the firefox omnijar layout places the central header directory at the start of the file (so all file headers and contents reside after it). You can take a look at the format by unpacking a firefox tarball or looking in a firefox installation for the omni.ja file. There's also a description here (though it appears that the diagrams have succumbed to bitrot).

If this behavior is essential or particularly useful in the general case, it'd be great if it could be configurable, or maybe those checks shouldn't be done if ArchiveOffset::Known is used.

To Reproduce

  1. Modify the example extract program to open the archive with
    zip::ZipArchive::with_config(zip::read::Config { archive_offset: zip::read::ArchiveOffset::Known(0) }, file)
    
  2. Run the extract example on the Firefox omni.ja file (described previously).

Expected behavior
Extraction succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions