]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
enforce minimum compression level limit
authorYann Collet <cyan@fb.com>
Sat, 22 Sep 2018 23:10:10 +0000 (16:10 -0700)
committerYann Collet <cyan@fb.com>
Sat, 22 Sep 2018 23:10:10 +0000 (16:10 -0700)
using ZSTD_minCLevel()

programs/zstdcli.c

index 3d4548a4b703b0472d517c06903af642d6c67820..6b2c5d10a8b8b3982ea21df1801be6a765115392 100644 (file)
@@ -37,8 +37,8 @@
 #ifndef ZSTD_NODICT
 #  include "dibio.h"  /* ZDICT_cover_params_t, DiB_trainFromFiles() */
 #endif
-#define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_maxCLevel */
-#include "zstd.h"     /* ZSTD_VERSION_STRING */
+#define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_minCLevel */
+#include "zstd.h"     /* ZSTD_VERSION_STRING, ZSTD_maxCLevel */
 
 
 /*-************************************
@@ -634,9 +634,11 @@ int main(int argCount, const char* argv[])
                     if (longCommandWArg(&argument, "--fast")) {
                         /* Parse optional acceleration factor */
                         if (*argument == '=') {
+                            U32 const maxFast = (U32)-ZSTD_minCLevel();
                             U32 fastLevel;
                             ++argument;
                             fastLevel = readU32FromChar(&argument);
+                            if (fastLevel > maxFast) fastLevel = maxFast;
                             if (fastLevel) {
                               dictCLevel = cLevel = -(int)fastLevel;
                             } else {