]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fixed decompress_usingDict not propagating corrupted dictionary error
authorSean Purcell <me@seanp.xyz>
Thu, 12 Jan 2017 01:31:06 +0000 (17:31 -0800)
committerSean Purcell <me@seanp.xyz>
Thu, 12 Jan 2017 01:31:34 +0000 (17:31 -0800)
lib/decompress/zstd_decompress.c
tests/fuzzer.c

index 02f3bf45504a0e2623252955c9142389127d1e1d..30198f036acdd5cdf67e79e0ffd7b2bc3907481c 100644 (file)
@@ -1444,7 +1444,7 @@ size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
 #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1)
     if (ZSTD_isLegacy(src, srcSize)) return ZSTD_decompressLegacy(dst, dstCapacity, src, srcSize, dict, dictSize);
 #endif
-    ZSTD_decompressBegin_usingDict(dctx, dict, dictSize);
+    CHECK_F(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize));
     ZSTD_checkContinuity(dctx, dst);
     return ZSTD_decompressFrame(dctx, dst, dstCapacity, src, srcSize);
 }
index 37fa8dcede5202813eddfc4b6b7fc848962289c5..19b199ab9c04736ce78393382154aff03f3d2e56 100644 (file)
@@ -312,6 +312,14 @@ static int basicUnitTests(U32 seed, double compressibility)
                   if (r != CNBuffSize) goto _output_error);
         DISPLAYLEVEL(4, "OK \n");
 
+        DISPLAYLEVEL(4, "test%3i : dictionary containing only header should return error : ", testNb++);
+        {
+          const size_t ret = ZSTD_decompress_usingDict(
+              dctx, decodedBuffer, CNBuffSize, compressedBuffer, cSize,
+              "\x37\xa4\x30\xec\x11\x22\x33\x44", 8);
+          if (ZSTD_getErrorCode(ret) != ZSTD_error_dictionary_corrupted) goto _output_error;
+        }
+
         ZSTD_freeCCtx(cctx);
         ZSTD_freeDCtx(dctx);
         free(dictBuffer);