-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
zlib.createUnzip does not throw error on unexpected end of file #2043
Comments
Does it throw if you do |
No, it "works" silently. The same behavior as the async version. But the file is definitely corrupted. It is smaller than the original, and Node.JS should throw error as |
/cc @indutny |
There cause is in https://github.com/nodejs/io.js/blob/master/src/node_zlib.cc#L270-L291. There are few errors not handled there. In the case I described, there is a fatal Maybe it would be beneficial to look at other zlib wrappers, like |
Does seem like that error case should be handled. Clean up resources and emit error on async and throw if sync. |
I'd be happy to help any folks new to the project track this down. |
@chrisdickinson I was reading this page http://zlib.net/zlib_how.html
If I understand this correctly,
then it means that
Can this mean we have malformed data? I tried this patch
And it gives me
for the OP's case. |
NVM. That is wrong. It breaks |
@chrisdickinson Thanks for being available as a mentor 👍 Would you mind adding some of your contact info for people willing to pick that up so that they can contact you when/if they need guidance? |
@chrisdickinson I would love to learn from you as your mentee :-) |
@misterdjules Great idea — my email is chris at neversaw dot us — that is probably the best way to get ahold of me. @thefourtheye Rad! I can start looking at this issue tomorrow AM and would be happy to answer any questions via email or issue comment. I can also work out a time to make myself available on IRC in #io.js if that helps as well! |
@chrisdickinson Cool. I am in Indian Standard Time. I ll start with the mail communication. I am also available in IRC as well :-) |
The very verbose zlib manual indicates that both inflate and deflate return Z_OK when progress was made but more work is left. |
Check for unexpected end-of-file error when decompressing. If the output buffer still has space after decompressing and deflate returned Z_OK or Z_BUF_ERROR - that means unexpected end-of-file. Added test-zlib-truncated.js for the case of truncated input. Fixed the zlib dictionary test to not end the inflate stream on a truncated output (no crc) of deflate Fixes: #2043 PR-URL: #2595 Reviewed-By: Trevor Norris <[email protected]>
Here's the code:
I take a big valid
gz
file and do:Now
test.gz
is an unfinished archive:...But the aforementioned script shows DONE on this (unfinished) archive. No error.
There should be.
The text was updated successfully, but these errors were encountered: