]> git.ipfire.org Git - thirdparty/zstd.git/commit
[bug] Fix dictContentType when reprocessing cdict
authorNick Terrell <terrelln@fb.com>
Mon, 5 Oct 2020 22:17:44 +0000 (15:17 -0700)
committerNick Terrell <terrelln@fb.com>
Mon, 12 Oct 2020 19:46:10 +0000 (12:46 -0700)
commit7083f790084be3f8b9b58c365e55c3a1df7de236
treeebe23a33c7c850c3205cdb194de96ba9d50eb18a
parentb951ad20a2af45a70f40caa8015a0be728eba463
[bug] Fix dictContentType when reprocessing cdict

Conditions to trigger:
* CDict is loaded as raw content.
* CDict starts with the zstd dictionary magic number.
* The CDict is reprocessed (not attached or copied).
* The new API is used (streaming or `ZSTD_compress2()`).

Bug: The dictionary is loaded as a zstd dictionary, not a raw content
dictionary, because the dict content type is set to `ZSTD_dct_auto`.

Fix: Pass in the dictionary content type from cdict creation to the call
to `ZSTD_compress_insertDictionary()`.

Test: Added a test case that exposes the bug, and fixed the raw
content tests to not modify the `dictBuffer`, which makes all future
tests with the `dictBuffer` raw content, which doesn't seem intentional.
lib/compress/zstd_compress.c
tests/fuzzer.c