From 695d154cac251c4ae2e2a438af21f0455a4c4149 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 8 Feb 2024 16:14:14 -0800 Subject: [PATCH 1/2] fuzz: control debuglevel from Makefile and make the compilation faster --- tests/fuzz/Makefile | 2 +- tests/fuzz/fuzz.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fuzz/Makefile b/tests/fuzz/Makefile index 525e396bc..554bd10d5 100644 --- a/tests/fuzz/Makefile +++ b/tests/fuzz/Makefile @@ -257,7 +257,7 @@ corpora: $(patsubst %,corpora/%,$(FUZZ_TARGETS)) seedcorpora: $(patsubst %,corpora/%_seed_corpus.zip,$(FUZZ_TARGETS)) regressiontest: corpora - CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" $(PYTHON) ./fuzz.py build all + CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" $(PYTHON) ./fuzz.py build all --debug=$(DEBUGLEVEL) $(PYTHON) ./fuzz.py regression all clean: diff --git a/tests/fuzz/fuzz.py b/tests/fuzz/fuzz.py index 058fca813..c489b8fa6 100755 --- a/tests/fuzz/fuzz.py +++ b/tests/fuzz/fuzz.py @@ -492,6 +492,7 @@ def build(args): subprocess.check_call(clean_cmd) build_cmd = [ 'make', + '-j', cc_str, cxx_str, cppflags_str, From b0e8580dc7f71881361f3a6fe46841af9d70bedf Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 8 Feb 2024 16:38:20 -0800 Subject: [PATCH 2/2] fix fuzz issue 5131069967892480 --- lib/compress/zstd_opt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index 0449204dd..c2ec2a9ed 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -1216,6 +1216,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms, if ( (optLevel >= 1) /* additional check only for higher modes */ && (prevMatch.litlen == 0) /* replace a match */ && (LL_INCPRICE(1) < 0) /* ll1 is cheaper than ll0 */ + && LIKELY(ip + cur < iend) ) { /* check next position, in case it would be cheaper */ int with1literal = prevMatch.price + LIT_PRICE(ip+cur) + LL_INCPRICE(1);