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

ZipException: File header and local file header mismatch #363

Closed
aditya-agg opened this issue Oct 6, 2021 · 5 comments
Closed

ZipException: File header and local file header mismatch #363

aditya-agg opened this issue Oct 6, 2021 · 5 comments
Assignees
Labels
bug Something isn't working resolved

Comments

@aditya-agg
Copy link

aditya-agg commented Oct 6, 2021

Hi, I have created zip using zip4j and it is failing with the mentioned exception during unzipping.
Zip file is created using following code

File outputFile = new File(zipFile);
outputFile.getParentFile().mkdirs();
ZipFile outputZippedFile = new ZipFile(zipFile);
ZipParameters zipParameters = new ZipParameters();
zipParameters.setSymbolicLinkAction(ZipParameters.SymbolicLinkAction.INCLUDE_LINK_ONLY);
outputZippedFile.addFolder(new File(sourceFolder), zipParameters);

I have been able to unzip it using other tools, but getting exception with Zip4j. Attaching zip file for reference
zipFile.zip

@srikanth-lingala
Copy link
Owner

The problem entry in the zip is this file: zip-source-directory/Co:\nfig. What was the name of the config file before this was added to the zip? That is, the name of this file in sourceFolder?

@aditya-agg
Copy link
Author

aditya-agg commented Oct 7, 2021

The zip is created to mimic the issue. Unfortunately, I cannot share the original zip. During debugging, I observed the exception being thrown when filename has special character. Also, local file headers are being set correctly, but file headers are believed to be truncated(as seen in intellij), but I am not sure.

@srikanth-lingala
Copy link
Owner

when filename has escape character.

Which character exactly was it in your case?

@aditya-agg
Copy link
Author

In mac OS, the name of this file is being shown as "Co/\nfig". However, I am able to unzip the zipfile with IOS unzip software, but not with zip4j.

@srikanth-lingala srikanth-lingala self-assigned this Oct 19, 2021
@srikanth-lingala srikanth-lingala added bug Something isn't working resolved and removed want feedback labels Oct 19, 2021
srikanth-lingala added a commit that referenced this issue Oct 19, 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