]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added control from frame content size at end of decompression 858/head
authorYann Collet <cyan@fb.com>
Thu, 21 Sep 2017 23:21:10 +0000 (16:21 -0700)
committerYann Collet <cyan@fb.com>
Thu, 21 Sep 2017 23:21:10 +0000 (16:21 -0700)
adding check at end of single-pass ZSTD_decompressFrame().
Check within ZSTD_decompressContinue() was already added in a previous patch : b3f33ccfb3b4fcc73df82126fd5ecfb751268fc6

lib/decompress/zstd_decompress.c
tests/fuzzer.c

index 91518990e0e9d6eab5293fcdcf38c980bb96af75..2abcc145e23a9e5859d619fae6573ec4ee47ed5d 100644 (file)
@@ -1546,6 +1546,10 @@ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
         if (blockProperties.lastBlock) break;
     }
 
+    if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+        if ((U64)(op-ostart) != dctx->fParams.frameContentSize) {
+            return ERROR(corruption_detected);
+    }   }
     if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
         U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
         U32 checkRead;
index 2bc5c9dfe61b35d08a1b810fb26e6c11773fbf52..bfa290c627808c51dfe8e51c899666478d2631f3 100644 (file)
@@ -811,7 +811,7 @@ static int basicUnitTests(U32 seed, double compressibility)
         }
         DISPLAYLEVEL(4, "OK \n");
 
-        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_auto should fail", testNb++);
+        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_auto should fail : ", testNb++);
         {
             size_t ret;
             MEM_writeLE32((char*)dictBuffer+2, ZSTD_MAGIC_DICTIONARY);
@@ -821,7 +821,7 @@ static int basicUnitTests(U32 seed, double compressibility)
         }
         DISPLAYLEVEL(4, "OK \n");
 
-        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_rawContent should pass", testNb++);
+        DISPLAYLEVEL(4, "test%3i : Loading rawContent starting with dict header w/ ZSTD_dm_rawContent should pass : ", testNb++);
         {
             size_t ret;
             MEM_writeLE32((char*)dictBuffer+2, ZSTD_MAGIC_DICTIONARY);