]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
detect early impossible decompression scenario in legacy decoder v0.5
authorYann Collet <cyan@fb.com>
Tue, 18 Oct 2016 20:48:32 +0000 (13:48 -0700)
committerYann Collet <cyan@fb.com>
Tue, 18 Oct 2016 20:48:32 +0000 (13:48 -0700)
NEWS
lib/legacy/zstd_v05.c

diff --git a/NEWS b/NEWS
index a9454b40ba016a05f3b55dcb086621d89b6de8f0..570d6679957a27b270d015f07f0fd7f72592609e 100644 (file)
--- 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
index 4c1c8c5e400848f42a3a194a91e986d50447243f..3cb5bb4afedd447183f79ebfc3555a2f674216e6 100644 (file)
@@ -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);