-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: compress/gzip: return different error for trailing garbage #61797
Comments
CC @dsnet |
According to RFC 1952, section 2.2:
Thus, when a gzip member terminates, the parser should correctly check whether there is a header for another gzip member. An "invalid header" error seems to be the right error given this grammar. |
In addition to what @dsnet said, I think it's possible to use the current API to figure out whether there might be trailing data. If
(The general ambiguity described in the second bullet is just what @dsnet pointed out; it's why the compress/gzip package isn't in a position to know whether there is trailing junk or a different kind of corruption. But you may be able to tell based on what your data looks like.) |
Thanks for the details, that is making sense and I don't want to complicate the code for nothing. I must say I would still love to have a distinguished error that would allow a developper to quickly be able to make the difference between an error regarding the first gzip header and the attempt at reading another gzip member from a multistream gzip. I imagine the value of the error could be changed to reflect that just after we manage to read the first member. go/src/compress/gzip/gunzip.go Line 273 in 24f83ed
What are your thoughts? Edit: Alternatively, if multistream is set to true, the error could be read as something such as "Invalid header in multi-stream gzip" |
@dsnet While the error is technically correct, I agree with @nikaiw that a having a distinct error would provide tremendous clarity. Something like To quote my rationale from #679861:
Footnotes
|
Hello,
Regarding #47809 , would you consider returning a different err ?
"gzip: invalid header" can be quite misleading when the error is actually because of trailing garbage.
The text was updated successfully, but these errors were encountered: