]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed wrong assert() position
authorYann Collet <cyan@fb.com>
Wed, 3 Oct 2018 19:43:59 +0000 (12:43 -0700)
committerYann Collet <cyan@fb.com>
Wed, 3 Oct 2018 19:43:59 +0000 (12:43 -0700)
could fire on invalid input.
blocking for afl tests.

programs/fileio.c

index b66426b1d22d2d9be3f6ab89c5286fe7ff5c52ac..ed3a29cda3dba682b2cb5f0eaee1cbcb3f5c40bb 100644 (file)
@@ -1449,12 +1449,12 @@ static void FIO_zstdErrorHelp(dRess_t* ress, size_t err, char const* srcFileName
     if (err == 0) {
         unsigned long long const windowSize = header.windowSize;
         U32 const windowLog = FIO_highbit64(windowSize) + ((windowSize & (windowSize - 1)) != 0);
-        U32 const windowMB = (U32)((windowSize >> 20) + ((windowSize & ((1 MB) - 1)) != 0));
-        assert(windowSize < (U64)(1ULL << 52));
         assert(g_memLimit > 0);
         DISPLAYLEVEL(1, "%s : Window size larger than maximum : %llu > %u\n",
                         srcFileName, windowSize, g_memLimit);
         if (windowLog <= ZSTD_WINDOWLOG_MAX) {
+            U32 const windowMB = (U32)((windowSize >> 20) + ((windowSize & ((1 MB) - 1)) != 0));
+            assert(windowSize < (U64)(1ULL << 52));   /* ensure now overflow for windowMB */
             DISPLAYLEVEL(1, "%s : Use --long=%u or --memory=%uMB\n",
                             srcFileName, windowLog, windowMB);
             return;