Skip to content
New issue

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

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

Already on GitHub? # to your account

ICSharpCode.SharpZipLib.Zip.ZipException: Wrong Central Directory signature #356

Closed
DmitriyKirakosyan opened this issue Jun 18, 2019 · 2 comments
Assignees
Labels
zip Related to ZIP file format

Comments

@DmitriyKirakosyan
Copy link

DmitriyKirakosyan commented Jun 18, 2019

File to test: https://dl.google.com/android/repository/sys-img/android-wear/x86-P_r02.zip.
SharpZipLib fails to unzip this file, while Windows10 is able to do it using Extract All... menu item.

Steps to reproduce

  1. Download the test file;
  2. Try to unzip it using SharpZipLib;
  3. Observe the Wrong Central Directory signature error.

Version of SharpZipLib

1.1.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet
@piksel
Copy link
Member

piksel commented Jun 18, 2019

Confirmed. This is due to the fact that the file has a Zip64 Central Directory, while not using any Zip64 extensions. It also contains a non-zip64 CD, but it seems to be corrupt.

The way SharpZipLib detects whether to use Zip64 is if any of the fields are set to all 1s (0xffff etc), and only then tries to find the Zip64 signature.
This means that unzip and other programs that just tries to find both headers at once works fine, while SharpZipLib (albeit correctly) complains about the invalid Central Directory.

We should probably attempt to find the Zip64 signature at once as well, this would make the library work more like most other zip-implementations and handle non-compliant zip files better.

@piksel piksel self-assigned this Jun 18, 2019
@piksel piksel added bug zip Related to ZIP file format and removed bug labels Jun 18, 2019
@piksel
Copy link
Member

piksel commented Jun 18, 2019

I made a new issue #357 for the root cause to link this and other issues into.

@piksel piksel closed this as completed Jan 13, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
zip Related to ZIP file format
Projects
None yet
Development

No branches or pull requests

2 participants