]> git.ipfire.org Git - thirdparty/zstd.git/commit
error on no forward progress 1204/head
authorYann Collet <cyan@fb.com>
Sat, 23 Jun 2018 00:58:21 +0000 (17:58 -0700)
committerYann Collet <cyan@fb.com>
Sat, 23 Jun 2018 00:58:21 +0000 (17:58 -0700)
commit31769ce7029fee2409ad52155d143b89aed5b692
tree2746fb1e04ebfde037151f0166f41b5f9788b1c9
parent3934e010a280e2899e710a4b4afe921b5b0593ba
error on no forward progress

streaming decoders, such as ZSTD_decompressStream() or ZSTD_decompress_generic(),
may end up making no forward progress,
(aka no byte read from input __and__ no byte written to output),
due to unusual parameters conditions,
such as providing an output buffer already full.

In such case, the caller may be caught in an infinite loop,
calling the streaming decompression function again and again,
without making any progress.

This version detects such situation, and generates an error instead :
ZSTD_error_dstSize_tooSmall when output buffer is full,
ZSTD_error_srcSize_wrong when input buffer is empty.

The detection tolerates a number of attempts before triggering an error,
controlled by ZSTD_NO_FORWARD_PROGRESS_MAX macro constant,
which is set to 16 by default, and can be re-defined at compilation time.
This behavior tolerates potentially existing implementations
where such cases happen sporadically, like once or twice,
which is not dangerous (only infinite loops are),
without generating an error, hence without breaking these implementations.
lib/decompress/zstd_decompress.c
tests/fuzzer.c
tests/zstreamtest.c