]> git.ipfire.org Git - thirdparty/zstd.git/commit
seekable decompression fixes (#2594)
authorAzat Khuzhin <a.khuzhin@semrush.com>
Wed, 5 May 2021 14:05:41 +0000 (17:05 +0300)
committerGitHub <noreply@github.com>
Wed, 5 May 2021 14:05:41 +0000 (10:05 -0400)
commit53a60e98dee5e4abc21be460b0234f6712617713
treea2505ce4cdf8b05ff1585a4fd7acf89db70b6e4a
parentc077f257b4deca408aee873b672705497e0a2ccb
seekable decompression fixes (#2594)

* seekable_format: fix from-file reading (not in-memory)

It tries to check the buffer boundary, but there is no buffer for
from-file reading.

* seekable_decompression: break when ZSTD_seekable_decompress() returns zero

* seekable_decompression_mem: break when ZSTD_seekable_decompress() returns zero

* seekable_format: cap the offset+len up to the last dOffset

This will allow to read the whole file w/o gotting corruption error if
the offset is more then the data left in file, i.e.:

    $ ./seekable_compression seekable_compression.c 8192 | head
    $ zstd -cdq seekable_compression.c.zst | wc -c
    4737

Before this patch:

    $ ./seekable_decompression seekable_compression.c.zst 0 10000000 | wc -c
    ZSTD_seekable_decompress() error : Corrupted block detected
    0

After:

    $ ./seekable_decompression seekable_compression.c.zst 0 10000000 | wc -c
    4737
contrib/seekable_format/examples/seekable_decompression.c
contrib/seekable_format/examples/seekable_decompression_mem.c
contrib/seekable_format/zstdseek_decompress.c