Skip to content

Commit 49c6d49

Browse files
Bimba Shresthaterrelln
Bimba Shrestha
authored andcommitted
[fuzz] msan uninitialized unsigned value (#1908)
Fixes new fuzz issue Credit to OSS-Fuzz * Initializing unsigned value * Initialilzing to 1 instead of 0 because its more conservative * Unconditionoally setting to check first and then checking zero * Moving bool to before block for c90 * Move check set before block
1 parent 5120883 commit 49c6d49

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/compress/zstd_compress.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2858,17 +2858,17 @@ size_t ZSTD_loadCEntropy(ZSTD_compressedBlockState_t* bs, void* workspace,
28582858
const BYTE* dictPtr = (const BYTE*)dict; /* skip magic num and dict ID */
28592859
const BYTE* const dictEnd = dictPtr + dictSize;
28602860
dictPtr += 8;
2861+
bs->entropy.huf.repeatMode = HUF_repeat_check;
28612862

28622863
{ unsigned maxSymbolValue = 255;
2863-
unsigned hasZeroWeights;
2864+
unsigned hasZeroWeights = 1;
28642865
size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)bs->entropy.huf.CTable, &maxSymbolValue, dictPtr,
28652866
dictEnd-dictPtr, &hasZeroWeights);
28662867

28672868
/* We only set the loaded table as valid if it contains all non-zero
28682869
* weights. Otherwise, we set it to check */
28692870
if (!hasZeroWeights)
28702871
bs->entropy.huf.repeatMode = HUF_repeat_valid;
2871-
else bs->entropy.huf.repeatMode = HUF_repeat_check;
28722872

28732873
RETURN_ERROR_IF(HUF_isError(hufHeaderSize), dictionary_corrupted);
28742874
RETURN_ERROR_IF(maxSymbolValue < 255, dictionary_corrupted);

0 commit comments

Comments
 (0)