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

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

Closed
mbach979 opened this issue Sep 1, 2021 · 2 comments
Assignees
Labels
bug Something isn't working resolved

Comments

@mbach979
Copy link

mbach979 commented Sep 1, 2021

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)

@srikanth-lingala
Copy link
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.

@srikanth-lingala srikanth-lingala self-assigned this Sep 3, 2021
@srikanth-lingala srikanth-lingala added bug Something isn't working resolved labels Sep 3, 2021
srikanth-lingala added a commit that referenced this issue Sep 5, 2021
@srikanth-lingala
Copy link
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
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

2 participants