From f7906d595500c04951643eb98c8f26405b01973f Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 18 Oct 2016 13:48:32 -0700 Subject: [PATCH] detect early impossible decompression scenario in legacy decoder v0.5 --- NEWS | 1 + lib/legacy/zstd_v05.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index a9454b40b..570d66799 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ v1.1.1 New : command -M#, --memory=, --memlimit=, --memlimit-decompress= to limit allowed memory consumption +Changed : zstd_errors.h is now part of include installation v1.1.0 New : contrib/pzstd, parallel version of zstd, by Nick Terrell diff --git a/lib/legacy/zstd_v05.c b/lib/legacy/zstd_v05.c index 4c1c8c5e4..3cb5bb4af 100644 --- a/lib/legacy/zstd_v05.c +++ b/lib/legacy/zstd_v05.c @@ -2032,13 +2032,14 @@ size_t HUFv05_decompress1X2_usingDTable( { BYTE* op = (BYTE*)dst; BYTE* const oend = op + dstSize; - size_t errorCode; const U32 dtLog = DTable[0]; const void* dtPtr = DTable; const HUFv05_DEltX2* const dt = ((const HUFv05_DEltX2*)dtPtr)+1; BITv05_DStream_t bitD; - errorCode = BITv05_initDStream(&bitD, cSrc, cSrcSize); - if (HUFv05_isError(errorCode)) return errorCode; + + if (dstSize <= cSrcSize) return ERROR(dstSize_tooSmall); + { size_t const errorCode = BITv05_initDStream(&bitD, cSrc, cSrcSize); + if (HUFv05_isError(errorCode)) return errorCode; } HUFv05_decodeStreamX2(op, &bitD, oend, dt, dtLog);