]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Resolve Coverity 1432392 Unintentional integer overflow 2293/head
authorAllan Jude <allan@klarasystems.com>
Thu, 3 Sep 2020 19:31:50 +0000 (19:31 +0000)
committerAllan Jude <allan@klarasystems.com>
Thu, 3 Sep 2020 19:31:50 +0000 (19:31 +0000)
Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression:
cdict->dictContentSize * 6U
with type unsigned int (32 bits, unsigned) is evaluated using 32-bit
arithmetic, and then used in a context that expects an expression of
type U64 (64 bits, unsigned).

lib/compress/zstd_compress.c

index 3f963b1cfff8bc11c9c6d6e8a053132feee728dd..68abb736a9586712ce7689ec1942d91a692d0d51 100644 (file)
@@ -3074,7 +3074,7 @@ ZSTD_compress_insertDictionary(ZSTD_compressedBlockState_t* bs,
 }
 
 #define ZSTD_USE_CDICT_PARAMS_SRCSIZE_CUTOFF (128 KB)
-#define ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER (6)
+#define ZSTD_USE_CDICT_PARAMS_DICTSIZE_MULTIPLIER (6ULL)
 
 /*! ZSTD_compressBegin_internal() :
  * @return : 0, or an error code */