-
Notifications
You must be signed in to change notification settings - Fork 318
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
Incorrect exception message shown for wrong password error #9
Comments
I experienced a similar bug, but in the context of AES decryption. The problem with this Exception conversion is that the "type" of the ZipException gets lost. More specifically: The type "WRONG_PASSWORD" gets converted into the type "UNKNOWN". This makes it hard or impossible to correctly identify an invalid password (without applying further workarounds). I suggest the following changes:
|
Nevertheless, thank you @srikanth-lingala for this excellent library. I just released the first version of the Android app "Secure Zip Notes" (which is still rather feature-limited): If our further plans with this app turn out to be successful, then I will make sure that you receive an adequate compensation. |
In the meantime, you can workaround this bug by checking the exception message: try {
final ZipInputStream is = zipFile.getInputStream(fileHeader);
...
} catch (ZipException e) {
if (e.getMessage().contains("Wrong Password")) {
...
}
} |
@AndrejsAlsevskis However, I think at the moment, zip4j does not set the exception type as wrong_password in this case. This type should be set. I will include it in the next release. @fkirc |
@srikanth-lingala Look for a code with a following comment. Cheers, |
That comment has been taken out of the official zip specification. I have read this already as part of the zip specification. Unfortunately, it did not help me much. I experimented a bit but I could not figure out a solution for it. What I also noticed a few years back is that, some other famous tools (like Winzip, 7Zip, etc) also extract the whole file before showing user a wrong password message dialog. This happened with those tools only for ZipCrypto and not AES. In case of AES, those tools had a wrong password dialog almost immediately, but with ZipCrypto it took a lot of processing (depending on the file size in the zip) before this dialog showed up, which made me believe this was the only way to figure out a wrong password for ZipCrypto. I could very well be wrong, and there probably is a way to figure it out. If so, I would highly appreciate if someone can point me in the right direction, except for the specification document, which is, unfortunately, not really helpful. |
Fixed in v2.1.0 |
Hi,
I'm using latest version v2.0.3 and I am getting incorrect exception messages when trying to unzip password-protected zip files created with 7zip using ZipCrypto enctyption method and providing wrong password.
Steps to reproduce:
The sample code above prints:
java.io.IOException: Reached end of entry, but crc verification failed for test.txt
The text was updated successfully, but these errors were encountered: