From: Yann Collet Date: Tue, 21 Jun 2016 10:17:26 +0000 (+0200) Subject: stronger fuzzer tests for ZBUFF_compressEnd() X-Git-Tag: v0.7.1~1^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2565971ea4a7ee211fa5a583b0aedf2e1e571bb4;p=thirdparty%2Fzstd.git stronger fuzzer tests for ZBUFF_compressEnd() --- diff --git a/programs/zbufftest.c b/programs/zbufftest.c index b890786cf..cdf3abef8 100644 --- a/programs/zbufftest.c +++ b/programs/zbufftest.c @@ -421,10 +421,15 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres } } /* final frame epilogue */ - { size_t dstBuffSize = cBufferSize - cSize; - size_t const flushError = ZBUFF_compressEnd(zc, cBuffer+cSize, &dstBuffSize); - CHECK (ZBUFF_isError(flushError), "flush error : %s", ZBUFF_getErrorName(flushError)); - cSize += dstBuffSize; + { size_t remainingToFlush = 1; + while (remainingToFlush) { + size_t const randomDstSize = FUZ_randomLength(&lseed, maxSampleLog); + size_t dstBuffSize = MIN(cBufferSize - cSize, randomDstSize); + remainingToFlush = ZBUFF_compressEnd(zc, cBuffer+cSize, &dstBuffSize); + CHECK (ZBUFF_isError(remainingToFlush), "flush error : %s", ZBUFF_getErrorName(remainingToFlush)); + DISPLAY("flush %u bytes : still within context : %i \n", (U32)dstBuffSize, (int)remainingToFlush); + cSize += dstBuffSize; + } } crcOrig = XXH64_digest(&xxhState);