]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fix fuzzer32 litCSize limit condition
authorYann Collet <yann.collet.73@gmail.com>
Wed, 4 Nov 2015 22:36:36 +0000 (23:36 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 4 Nov 2015 22:36:36 +0000 (23:36 +0100)
lib/zstd.c
lib/zstd_internal.h
lib/zstdhc.c

index db533f9a50d0e3c5198f7a36a74d54bd215e1f5c..776a5bca529bb3afa034e07b56428727284e6cf3 100644 (file)
 #define GB *(1U<<30)
 
 #define BLOCKSIZE (128 KB)                 /* define, for static allocation */
-#define MIN_SEQUENCES_SIZE (2 /*seqNb*/ + 2 /*dumps*/ + 3 /*seqTables*/ + 1 /*bitStream*/)
-#define MIN_CBLOCK_SIZE (3 /*litCSize*/ + MIN_SEQUENCES_SIZE)
 #define IS_RAW BIT0
 #define IS_RLE BIT1
 
index f6363645946c306d136ff2cd17e69ec23e35c707..ee0f67359aed64aab8f30e19a938de03181b4cdf 100644 (file)
@@ -214,6 +214,10 @@ void ZSTD_resetSeqStore(seqStore_t* ssPtr);
 #define MaxLL  ((1<<LLbits) - 1)
 #define MaxOff   31
 
+#define MIN_SEQUENCES_SIZE (2 /*seqNb*/ + 2 /*dumps*/ + 3 /*seqTables*/ + 1 /*bitStream*/)
+#define MIN_CBLOCK_SIZE (3 /*litCSize*/ + MIN_SEQUENCES_SIZE)
+
+
 /** ZSTD_storeSeq
     Store a sequence (literal length, literals, offset code and match length) into seqStore_t
     @offsetCode : distance to match, or 0 == repCode
index ccd25236225152271bc2b6013cd313d3c08eada0..fb10b4b101ffbdb623bb015471ae2c04c1e80efc 100644 (file)
@@ -953,7 +953,7 @@ static size_t ZSTD_HC_compress_generic (ZSTD_HC_CCtx* ctxPtr,
     {
         size_t cSize;
 
-        if (maxDstSize < 5) return ERROR(dstSize_tooSmall);   /* not enough space to store compressed block */
+        if (maxDstSize < 3 + MIN_CBLOCK_SIZE) return ERROR(dstSize_tooSmall);   /* not enough space to store compressed block */
 
         if (remaining < blockSize) blockSize = remaining;
         cSize = blockCompressor(ctxPtr, op+3, maxDstSize-3, ip, blockSize);