-
Notifications
You must be signed in to change notification settings - Fork 98
zstd.Decompress
returns no error on invalid input
#59
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
Comments
This one is a difference between the zstd cli & this Go zstd library in how size hint is interpreted. It looks like the payload you were able to generate has a size hint of 4 but the payload needs 20 bytes to decompress. in the zstd cli, it bails at the error: https://github.com/facebook/zstd/blob/585b5a10390831c7878feae12701f143f80ec9b8/programs/fileio.c#L1708 in this Go zstd library, we retry up to 3 times with a bigger destination buffer: https://github.com/DataDog/zstd/blob/1.x/zstd.go#L135-L140 (so starts at 4 then 8 then 16 then 32, we are able to decode). This is a side effect of allowing the user to provide a destination buffer is to retry with reallocating for her (so I guess you can say library design decision here) By adding some logging, you can see what's happening:
To double check, using the python zstd bindings (another author):
Marking as won't fix because the behavior is expected in current design |
@Viq111 But the input is corrupted. I don't see how it can be by design that it returns no error when that happens? Here is another example: a6f346dc6989c3dfc402a82599e1bc83c1f5f8b6.zst.gz zstd.exe -d a6f346dc6989c3dfc402a82599e1bc83c1f5f8b6.zst .. but your library returns nothing. It seems to happen when there is additional data on the input but it fails to decode the frame header. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.12.1 windows/amd64
What operating system and processor architecture are you using (
go env
)?Package version:
809b919c325d7887bff7bd876162af73db53e878
(v.1.4.0 tag)What did you do?
Fuzz test. Using
ref, refErr := zstd.Decompress(nil, data)
.Sample data: af046bc7b9294e2e85367bf8eb2bfa4de760bc06.zst.gz (gzipped to make github happy).
I got plenty of examples of this.
What did you expect to see?
An error. The commandline returns:
What did you see instead?
No error returned.
The text was updated successfully, but these errors were encountered: