]> git.ipfire.org Git - thirdparty/zstd.git/commit
Make ZSTD_getDictID_fromDDict() Read DictID from DDict 3290/head
authorW. Felix Handte <w@felixhandte.com>
Sat, 15 Oct 2022 02:53:03 +0000 (22:53 -0400)
committerW. Felix Handte <w@felixhandte.com>
Sat, 15 Oct 2022 02:53:03 +0000 (22:53 -0400)
commitd7841d150be6355d9dd06ccc433589c81a8fb1f8
tree581fab42cb2c7cdb518d80e6df1943894b0ecd42
parent9abecfbb7ec41172d5e3f3de82b38cd3324e6f08
Make ZSTD_getDictID_fromDDict() Read DictID from DDict

Currently this function actually reads the dict ID from the dictionary's
header, via `ZSTD_getDictID_fromDict()`. But during decompression the decomp-
ressor actually compares the dict ID in the frame header with the dict ID in
the DDict. Now of course the dict ID in the dictionary contents and the dict
ID in the DDict struct *should* be the same. But in cases of memory corrupt-
ion, where they can drift out of sync, it's misleading for this function to
read it again from the dict buffer rather then return the dict ID that will
actually be used.

Also doing it this way avoids rechecking the magic and so on and so it is a
tiny bit more efficient.
lib/decompress/zstd_ddict.c