From c5d6dde502e4e30c7de4476e82b459361fe2f486 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Sat, 30 Sep 2017 14:17:32 -0700 Subject: [PATCH] Don't `size -= 1` in ZSTD_adjustCParams() The window size could end up too small if the source size is 2^n + 1. Credit to OSS-Fuzz --- lib/compress/zstd_compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 4c2254abe..51cdeaf03 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -651,7 +651,7 @@ ZSTD_compressionParameters ZSTD_adjustCParams_internal(ZSTD_compressionParameter if (dictSize && (srcSize+1<2) /* srcSize unknown */ ) srcSize = minSrcSize; /* presumed small when there is a dictionary */ - else + else if (srcSize == 0) srcSize -= 1; /* unknown 0 => -1ULL : presumed large */ /* resize windowLog if input is small enough, to use less memory */ -- 2.47.2