From: Yann Collet Date: Mon, 5 Feb 2024 08:36:10 +0000 (-0800) Subject: fix uasan dictionary_stream_round_trip fuzz test X-Git-Tag: v1.5.6^2~70^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=641749fc0935b6905b2fcfaa362cedfc631f5960;p=thirdparty%2Fzstd.git fix uasan dictionary_stream_round_trip fuzz test --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index 20a30406a..eed331929 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -267,6 +267,7 @@ static U32 ZSTD_rawLiteralsCost(const BYTE* const literals, U32 const litLength, const optState_t* const optPtr, int optLevel) { + DEBUGLOG(8, "ZSTD_rawLiteralsCost (%u literals)", litLength); if (litLength == 0) return 0; if (!ZSTD_compressedLiterals(optPtr)) @@ -1204,7 +1205,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms, opt[cur] = opt[cur-1]; opt[cur].litlen = litlen; opt[cur].price = price; - if ((optLevel == 2) /* additional check only for high modes */ + if ( (optLevel == 2) /* additional check only for high modes */ && (prevMatch.litlen == 0) /* interrupt a match */ && (LL_INCPRICE(1) < 0) /* ll1 is cheaper than ll0 */ ) { @@ -1278,7 +1279,8 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms, inr-istart, cur, nbMatches, longestML); if ( (longestML > sufficient_len) - || (cur + longestML >= ZSTD_OPT_NUM) ) { + || (cur + longestML >= ZSTD_OPT_NUM) + || (ip + cur + longestML >= iend) ) { lastStretch.mlen = longestML; lastStretch.off = matches[nbMatches-1].off; lastStretch.litlen = 0; diff --git a/tests/Makefile b/tests/Makefile index c31e75005..2f33e1d0f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -251,8 +251,9 @@ checkTag.o : $(ZSTDDIR)/zstd.h clean: $(MAKE) -C $(ZSTDDIR) clean $(MAKE) -C $(PRGDIR) clean - $(RM) -fR $(TESTARTEFACT) - $(RM) -rf tmp* # some test directories are named tmp* + $(MAKE) -C fuzz clean + $(RM) -R $(TESTARTEFACT) + $(RM) -r tmp* # some test directories are named tmp* $(RM) $(CLEAN) core *.o *.tmp result* *.gcda dictionary *.zst \ $(PRGDIR)/zstd$(EXT) $(PRGDIR)/zstd32$(EXT) \ fullbench-dll$(EXT) fuzzer-dll$(EXT) zstreamtest-dll$(EXT)