summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-09-28 21:57:50 (GMT)
committerYann Collet <cyan@fb.com>2018-09-28 21:57:50 (GMT)
commit21120549a7f35f924a66c7c071d0f5c69cf7e08a (patch)
tree188497d6edae9dfebea63711dea631012e766a8a /lib
parentcb917827f95a62dffb9575a2225e55721739b162 (diff)
downloadlz4-21120549a7f35f924a66c7c071d0f5c69cf7e08a.zip
lz4-21120549a7f35f924a66c7c071d0f5c69cf7e08a.tar.gz
lz4-21120549a7f35f924a66c7c071d0f5c69cf7e08a.tar.bz2
fixed improper hint
when LZ4F_decompress() decodes an uncompressed block, it provides an incorrect hint for next block when frame checksum is enabled and block checksum is not. Impact is low : the hint is just an hint, the decoder works whatever the amount of input provided. But the assumption that each call to LZ4F_decompress() would generate just one complete block if input size hint was respected was broken by this error.
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4frame.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 11e0975..547afa3 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -1474,7 +1474,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
}
dctx->tmpInTarget -= sizeToCopy; /* need to copy more */
nextSrcSizeHint = dctx->tmpInTarget +
- + dctx->frameInfo.contentChecksumFlag * 4 /* block checksum */
+ + dctx->frameInfo.blockChecksumFlag * 4 /* size for block checksum */
+ BHSize /* next header size */;
doAnotherStage = 0;
break;
@@ -1525,8 +1525,10 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
dctx->tmpInSize += sizeToCopy;
srcPtr += sizeToCopy;
if (dctx->tmpInSize < dctx->tmpInTarget) { /* need more input */
- nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) + BHSize;
- doAnotherStage=0;
+ nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize)
+ + dctx->frameInfo.blockChecksumFlag * 4 /* size for block checksum */
+ + BHSize /* next header size */;
+ doAnotherStage = 0;
break;
}
selectedIn = dctx->tmpIn;