From: Nick Terrell Date: Sat, 30 Sep 2017 21:17:32 +0000 (-0700) Subject: Don't `size -= 1` in ZSTD_adjustCParams() X-Git-Tag: v1.3.2~3^2~17^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5d6dde502e4e30c7de4476e82b459361fe2f486;p=thirdparty%2Fzstd.git 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 --- 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 */