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

ZIP files encrypted with Non-Unicode encoded password #207

Closed
ghost opened this issue Aug 31, 2020 · 2 comments
Closed

ZIP files encrypted with Non-Unicode encoded password #207

ghost opened this issue Aug 31, 2020 · 2 comments
Labels
enhancement Request a new feature.

Comments

@ghost
Copy link

ghost commented Aug 31, 2020

Description

If you create a ZIP file in Windows, and you use a password with non-ASCII characters to encrypt it, its password encoding may not be in Unicode. Therefore, libzip will not be able to decrypt the file.

Solution

I hope libzip can offer a parameter which does the same thing as The Unarchiver's -E/-password-encoding parameter.

See also: Repo of the XADMaster library, used by The Unarchiver

Additional information

Test files can be found in KDE Bug 393901 Comment 6.

Steps to reproduce
  1. Download KDE Bug 393901 attachment 118030
  2. In that ZIP file, there is another ZIP file called hello_cp1250.zip.
  3. Try extracting the file inside hello_cp1250.zip with the password žena.
    It will fail because the password is in cp1250 encoding.
@ghost ghost added the enhancement Request a new feature. label Aug 31, 2020
@ghost
Copy link
Author

ghost commented Aug 31, 2020

From this comment (which is related to the filename encoding, however), does that mean programs using libzip (e.g. KDE Ark) should have their own encoding conversion implementation?

@0-wiz-0
Copy link
Member

0-wiz-0 commented Aug 31, 2020

libzip makes no assumptions about the encoding of the password. I had to remove the trailing newline for the test, but then this worked fine:

> unset LC_CTYPE                                              
> hexdump -C pass_cp1250.txt 
00000000  9e 65 6e 61                                       |.ena|
00000004
> ziptool hello_cp1250.zip set_password `cat pass_cp1250.txt ` cat 0
HELLO!

libzip just takes the bytes as given and does not check any encoding. The only assumption it makes is that the password can be passed to strdup, i.e. there are no NUL bytes in it.

@0-wiz-0 0-wiz-0 closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant