]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Backport fix from commit 125d817
authorNick Terrell <terrelln@fb.com>
Tue, 18 Oct 2016 21:52:34 +0000 (14:52 -0700)
committerNick Terrell <terrelln@fb.com>
Tue, 18 Oct 2016 21:52:34 +0000 (14:52 -0700)
This fixes a read of unitialized memory.
Full commit hash: 125d81774fe87a2bc18023d999d8e510678c38fb.

lib/legacy/zstd_v05.c

index a8045aea007629ac91a40d833079b127bd734944..06dba06678612d48a9f392ff05bf499f884afddc 100644 (file)
@@ -2944,6 +2944,7 @@ size_t ZSTDv05_decodeLiteralsBlock(ZSTDv05_DCtx* dctx,
         {
             size_t litSize, litCSize, singleStream=0;
             U32 lhSize = ((istart[0]) >> 4) & 3;
+            if (srcSize < 5) return ERROR(corruption_detected);   /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */
             switch(lhSize)
             {
             case 0: case 1: default:   /* note : default is impossible, since lhSize into [0..3] */