]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[libzstd] Don't check the dictID in fuzzing mode
authorNick Terrell <terrelln@fb.com>
Tue, 9 Apr 2019 02:57:41 +0000 (19:57 -0700)
committerNick Terrell <terrelln@fb.com>
Tue, 9 Apr 2019 02:57:41 +0000 (19:57 -0700)
When `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is defined don't check
the dictID. This check makes the fuzzers job harder, and it is at the
very beginning.

lib/decompress/zstd_decompress.c

index aa7f6f58042d7609575fb3344102760bddadedab..14cc12a412fa95c9985b7267d80cca1b5910c8f2 100644 (file)
@@ -427,8 +427,13 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he
     size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
     if (ZSTD_isError(result)) return result;    /* invalid header */
     RETURN_ERROR_IF(result>0, srcSize_wrong, "headerSize too small");
+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+    /* Skip the dictID check in fuzzing mode, because it makes the search
+     * harder.
+     */
     RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
                     dictionary_wrong);
+#endif
     if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0);
     return 0;
 }