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

Add a different error code for truncated ZIPs #416

Closed
fdegros opened this issue Oct 6, 2023 · 3 comments
Closed

Add a different error code for truncated ZIPs #416

fdegros opened this issue Oct 6, 2023 · 3 comments
Labels
enhancement Request a new feature.

Comments

@fdegros
Copy link

fdegros commented Oct 6, 2023

Description

When libzip tries to open an incomplete (truncated) ZIP archive, it fails with the error code ZIP_ER_NOZIP "Not a zip archive".

Solution

Would it be possible to distinguish the two situations by returning different error codes?

  • The file doesn't look like a ZIP archive at all.
    In this case ZIP_ER_NOZIP "Not a zip archive" is appropriate.
  • The file looks like the beginning of a (truncated but otherwise valid) ZIP archive.
    In this case, a different error code (eg ZIP_ER_TRUNCATED "Truncated zip archive") would be preferred.

Additional context

Around 2% of all the ZIP archives that are opened by the ChromeOS Files App fail because of the ZIP_ER_NOZIP error. This percentage is stable over time, and it looks quite high. I am wondering if this is due to truncated ZIPs, or if there is another issue at play.

@fdegros fdegros added the enhancement Request a new feature. label Oct 6, 2023
@dillof
Copy link
Member

dillof commented Oct 6, 2023

This sounds like a good idea and shouldn't be hard to implement.

@0-wiz-0
Copy link
Member

0-wiz-0 commented Mar 15, 2024

I've just implemented this - let us know how this changed your percentage of invalid zip archives!
Thanks for the suggestion.

@fdegros
Copy link
Author

fdegros commented Mar 20, 2024

Thanks. I confirm this is implemented.

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

3 participants