]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix broken assertion 1068/head
authorNick Terrell <terrelln@fb.com>
Wed, 21 Mar 2018 23:20:30 +0000 (16:20 -0700)
committerNick Terrell <terrelln@fb.com>
Wed, 21 Mar 2018 23:20:30 +0000 (16:20 -0700)
The `avgJobSize` must not be lower than 256 KB for single-pass mode.
In `zstd.h` we say the minimum value for `ZSTD_p_jobSize` is 1 MB,
so ensure that we always pick a size >= 1 MB.

Found by libFuzzer fuzzer tests with large input limits.

lib/compress/zstdmt_compress.c

index c7b08cbce8dd1c0e97666580758c6c86698c2042..c7a205d8c757e0a6af197d06511831c7842daf99 100644 (file)
@@ -1029,7 +1029,7 @@ static size_t ZSTDMT_computeTargetJobLog(ZSTD_CCtx_params const params)
 {
     if (params.ldmParams.enableLdm)
         return MAX(21, params.cParams.chainLog + 4);
-    return params.cParams.windowLog + 2;
+    return MAX(20, params.cParams.windowLog + 2);
 }
 
 static size_t ZSTDMT_computeOverlapLog(ZSTD_CCtx_params const params)