From: Yann Collet Date: Tue, 21 Jun 2016 12:04:57 +0000 (+0200) Subject: fix : ZBUFF_compressEnd() gives right amount remaining to flush, including future... X-Git-Tag: v0.7.1~1^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa29226b7ce67c836aa8452685a5f6fcfeaeb065;p=thirdparty%2Fzstd.git fix : ZBUFF_compressEnd() gives right amount remaining to flush, including future epilogue --- diff --git a/NEWS b/NEWS index 0e8d87d62..ac832b12d 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ v0.7.1 +fixed : ZBUFF_compressEnd() called multiple times with too small `dst` buffer, reported by Christophe Chevalier fixed : corruption issue, reported by cj modified : checksum enabled by default in command line mode diff --git a/lib/compress/zbuff_compress.c b/lib/compress/zbuff_compress.c index d4ea217c2..023f92594 100644 --- a/lib/compress/zbuff_compress.c +++ b/lib/compress/zbuff_compress.c @@ -297,7 +297,7 @@ size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr) op += outSize; if (remainingToFlush) { *dstCapacityPtr = op-ostart; - return remainingToFlush; + return remainingToFlush + (ZSTD_BLOCKHEADERSIZE * (zbc->stage != ZBUFFcs_final)); } } if (zbc->stage == ZBUFFcs_final) { zbc->stage = ZBUFFcs_init; *dstCapacityPtr = op-ostart; return 0; }