]> git.ipfire.org Git - thirdparty/zstd.git/commit
decompress: changed error code when input is too large 1135/head
authorYann Collet <cyan@fb.com>
Mon, 14 May 2018 22:32:28 +0000 (15:32 -0700)
committerYann Collet <cyan@fb.com>
Mon, 14 May 2018 22:32:28 +0000 (15:32 -0700)
commitd59cf02df0938c3147f4290f48cf3e533129406e
tree70a47c95dc74c4b6672d497d9bd4b522be2f74b4
parent174bd3d4a7c7b32c22e6d810b6d3bcadcffb1a2f
decompress: changed error code when input is too large

ZSTD_decompress() can decompress multiple frames sent as a single input.
But the input size must be the exact sum of all compressed frames, no more.

In the case of a mistake on srcSize, being larger than required,
ZSTD_decompress() will try to decompress a new frame after current one, and fail.
As a consequence, it will issue an error code, ERROR(prefix_unknown).

While the error is technically correct
(the decoder could not recognise the header of _next_ frame),
it's confusing, as users will believe that the first header of the first frame is wrong,
which is not the case (it's correct).
It makes it more difficult to understand that the error is in the source size, which is too large.

This patch changes the error code provided in such a scenario.
If (at least) a first frame was successfully decoded,
and then following bytes are garbage values,
the decoder assumes the provided input size is wrong (too large),
and issue the error code ERROR(srcSize_wrong).
lib/decompress/zstd_decompress.c
tests/fuzzer.c