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

ZipFile can be constructed with a null File causing NPE some time later #263

Closed
mdaloia opened this issue Nov 27, 2020 · 2 comments
Closed
Assignees
Labels
bug Something isn't working resolved
Projects

Comments

@mdaloia
Copy link

mdaloia commented Nov 27, 2020

Current version (2.6.4) allows to construct a ZipFile with a null File reference: (i.e. new ZipFile((File) null)) without proper validation. This does not happen if you use the constructor with the String argument as internally it does a new File(string) and if the string is null the File constructor throws a NPE.

The consequence of this is that when you want to do an operation with the ZipFile instance (e.g. zipFile.getFileHeaders() it throws a NPE on this line.

To avoid these scenarios, it should be properly validated on construction of ZipFile if accepting a null reference as File is not valid later.

On previous versions (1.3.2) there was a check that somehow on later releases it was removed (particularly on this commit).
This is 1.3.2:
image

@srikanth-lingala
Copy link
Owner

Thanks for pointing it out. I will add this check.

@srikanth-lingala srikanth-lingala self-assigned this Dec 5, 2020
@srikanth-lingala srikanth-lingala added this to To do in Zip4j via automation Feb 7, 2021
@srikanth-lingala srikanth-lingala moved this from To do to Review in Zip4j Feb 7, 2021
@srikanth-lingala srikanth-lingala added bug Something isn't working resolved and removed in-progress labels Feb 7, 2021
@srikanth-lingala
Copy link
Owner

Issue fixed in v2.7.0 which was 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
Zip4j
  
Done
Development

No branches or pull requests

2 participants