Skip to content

Entry count overflow #291

Closed
Closed

Description

@tgrunwald

Steps to reproduce

  1. Prepare a zip file with more then 65536 entries
  2. Check the number of entries using similar code:
    using (var zip = new ZipFile(pathToZip))
    {
    Console.WriteLine("Entries count {zip.Count}");
    }

Expected behavior

It should display the exact number of files stored in zip file

Actual behavior

It displays (number_of_files & 0xFFFF)

Version of SharpZipLib

1.0.0.999

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Activity

  1. piksel commented on Dec 10, 2018

    @piksel
    Member

    The maximum amount of entries supported by the original zip format is 65535 (stored in two bytes in the header). If the zip file contains more than that it should set it's entry count to 0xFFFF, putting the real count inside the extended Zip64 header. How were you doing step 1?

  2. tgrunwald commented on Dec 11, 2018

    @tgrunwald
    Author

    The zip file I tried to examine is part of game Kingdom Come: Deliverance (Localization\English.pak). So the file was created using Cryengine resource compiler. When I opened the file with 7-zip, it has shown 75405 files, while opening it with the code above has shown only 9869. Then I tried Ionic.zip and it also says, there is 75405 files inside.

  3. piksel commented on Jan 30, 2019

    @piksel
    Member

    The overflow is in whatever created the archive. Instead of putting a 0xFFFF in the length field that would indicate that the extended header should be used, they just put the bottom 16 bits of the length in the field.
    It's possible to change the logic to look for Zip64 headers regardless of the length value.

    A PR would be welcomed!

  4. added
    enhancementFeature request or other improvements of existing functionality
    zipRelated to ZIP file format
    on Jan 30, 2019
  5. piksel commented on Jun 18, 2019

    @piksel
    Member

    Closed in favour of #357

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

    enhancementFeature request or other improvements of existing functionalityhelp wantedzipRelated to ZIP file format

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions