]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Don't `size -= 1` in ZSTD_adjustCParams() 878/head
authorNick Terrell <terrelln@fb.com>
Sat, 30 Sep 2017 21:17:32 +0000 (14:17 -0700)
committerNick Terrell <terrelln@fb.com>
Sat, 30 Sep 2017 21:20:06 +0000 (14:20 -0700)
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

index 4c2254abe9c9abc5e8267743bf7d7af30ad3aa36..51cdeaf032b149acf853381af7ef6d4a9092cd55 100644 (file)
@@ -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 */