Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When searching for the Zip64 end of central directory locator, pay attention to its fixed size. #408

Merged
merged 3 commits into from
Jan 27, 2020

Conversation

Numpsy
Copy link
Contributor

@Numpsy Numpsy commented Jan 6, 2020

#403 / #375 - the Zip64 end of central directory locator has a fixed 20 byte length, but the calls to LocateBlockWithSignature were specifying a fixed size of 0 and a dynamic size of 0x1000, which meant that the signature bytes could incorrectly be matched in a location other than where they should be (20 bytes prior to the end of central directory signature)

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 6, 2020

(Might also be worth adding an extra unit test with a file crafted to fall over 403)

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 7, 2020

Added a simple unit test that fails with the existing code and passes with the change

@piksel piksel self-requested a review January 10, 2020 18:58
Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems valid. I was worried about compability with "special" files, like self-extractors etc. would suffer from the stricter search parameters, but I have not found any evidence of this. Sometimes it's hard to tell if things in this library are intentional or mistakes/unpolished.

@piksel piksel merged commit 6ee0f12 into icsharpcode:master Jan 27, 2020
@Numpsy Numpsy deleted the rw/403 branch January 29, 2020 16:08
@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 29, 2020

I hadn't considered a different structure in self extractors, but I don't know enough about the differences to say either way.

@piksel
Copy link
Member

piksel commented Feb 1, 2020

@Numpsy Well, one of the interesting parts about the zip format is that, compared to most other file formats, it is basically read from the end. The "true" entry point into the data structure is the "end of central directory record". This means that you can prepend other data before the file entries, like for example a windows PE binary or an image. This means that a file can be both a valid .exe and a valid .zip at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants