From: Nick Terrell Date: Tue, 9 Apr 2019 02:57:41 +0000 (-0700) Subject: [libzstd] Don't check the dictID in fuzzing mode X-Git-Tag: v1.4.0^2~8^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfcd5b81d7a1f3612503e0e6ef0c6fe275e7017a;p=thirdparty%2Fzstd.git [libzstd] Don't check the dictID in fuzzing mode 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. --- diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index aa7f6f580..14cc12a41 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -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; }