Skip to content

ZipInputStream not finding next entry if entry is a folder with a Data Descriptor Still Not Fixed #354

Closed
@mbach979

Description

@mbach979

I believe this issue is still not fixed (tested in 2.9.0). The attached simple example of writing a zip archive with just two directories using ZipOutputStream and then reading with ZipInputStream fails to read the second entry.

The offending code seems to be in ZipInputStream.read(byte[], int, int) lines 155-157:
if (localFileHeader.isDirectory()) { return -1; }
Since this stops reading before endOfCompressedDataRecord() can be called, and subsequently read the data descriptor block. Reading the next entry then silently fails because the signature is for a data descriptor and not a local file header.

Zip4jDirectoryDataDescriptorBug.zip

Originally posted by @mbach979 in #309 (comment)

Activity

added a commit that references this issue on Sep 3, 2021

#354 Skip checking for directory when reading entries

srikanth-lingala

srikanth-lingala commented on Sep 3, 2021

@srikanth-lingala
Owner

Thanks for your analysis and also the sample code to test the issue. It really helped. I fixed the issue and I will include the fix in next release.

added a commit that references this issue on Sep 5, 2021

#354 Fix failing test

srikanth-lingala

srikanth-lingala commented on Nov 18, 2021

@srikanth-lingala
Owner

Fixed in v2.9.1 released today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingresolved

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @srikanth-lingala@mbach979

      Issue actions

        ZipInputStream not finding next entry if entry is a folder with a Data Descriptor Still Not Fixed · Issue #354 · srikanth-lingala/zip4j