]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
update minimum threshold for max block size
authorDanielle Rozenblit <drozenblit@fb.com>
Wed, 11 Jan 2023 19:09:57 +0000 (11:09 -0800)
committerDanielle Rozenblit <drozenblit@fb.com>
Wed, 11 Jan 2023 19:09:57 +0000 (11:09 -0800)
lib/compress/zstd_compress.c
lib/zstd.h
tests/fuzz/zstd_helpers.c

index e84ed9f270a6cb195d9e78aa7393eeecba6773ed..e27cbd6133dd2a4e847ddaa789b6491b07d2774c 100644 (file)
@@ -361,7 +361,6 @@ size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel)
     ZSTD_memset(cctxParams, 0, sizeof(*cctxParams));
     cctxParams->compressionLevel = compressionLevel;
     cctxParams->fParams.contentSizeFlag = 1;
-    // cctxParams->maxBlockSize = ZSTD_BLOCKSIZE_MAX;
     return 0;
 }
 
@@ -617,7 +616,7 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
         return bounds;
 
     case ZSTD_c_maxBlockSize:
-        bounds.lowerBound = 1;
+        bounds.lowerBound = ZSTD_BLOCKSIZE_MAX_MIN;
         bounds.upperBound = ZSTD_BLOCKSIZE_MAX;
         return bounds;
 
index 4437a2461d464e9d63213d6b7506db25bcba1377..2287886858cb4e4d1147ec8bd76f31b027a0f906 100644 (file)
@@ -141,6 +141,7 @@ ZSTDLIB_API const char* ZSTD_versionString(void);
 
 #define ZSTD_BLOCKSIZELOG_MAX  17
 #define ZSTD_BLOCKSIZE_MAX     (1<<ZSTD_BLOCKSIZELOG_MAX)
+#define ZSTD_BLOCKSIZE_MAX_MIN 1 << 10 /* The minimum valid max blocksize. Maximum blocksizes smaller than this make compressBound() inaccurate. */
 
 
 /***************************************
index 0f602d1db931d5f3a414542b442540876c70c076..ab243f1ec7368f8e1a3535f43c19b24439e8d58e 100644 (file)
@@ -104,7 +104,7 @@ void FUZZ_setRandomParameters(ZSTD_CCtx *cctx, size_t srcSize, FUZZ_dataProducer
     setRand(cctx, ZSTD_c_useBlockSplitter, 0, 2, producer);
     setRand(cctx, ZSTD_c_deterministicRefPrefix, 0, 1, producer);
     setRand(cctx, ZSTD_c_prefetchCDictTables, 0, 2, producer);
-    setRand(cctx, ZSTD_c_maxBlockSize, 1 << 12, ZSTD_BLOCKSIZE_MAX, producer);
+    setRand(cctx, ZSTD_c_maxBlockSize, ZSTD_BLOCKSIZE_MAX_MIN, ZSTD_BLOCKSIZE_MAX, producer);
     if (FUZZ_dataProducer_uint32Range(producer, 0, 1) == 0) {
       setRand(cctx, ZSTD_c_srcSizeHint, ZSTD_SRCSIZEHINT_MIN, 2 * srcSize, producer);
     }