Test for incorrect pledgeSrcSize earlier

This commit is contained in:
Nick Terrell
2018-02-01 12:04:05 -08:00
parent 727bb7f090
commit 48acaddff9
2 changed files with 23 additions and 2 deletions
+7
View File
@@ -2096,6 +2096,13 @@ static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx,
if (ZSTD_isError(cSize)) return cSize;
cctx->consumedSrcSize += srcSize;
cctx->producedCSize += (cSize + fhSize);
if (cctx->appliedParams.fParams.contentSizeFlag) { /* control src size */
if (cctx->consumedSrcSize+1 > cctx->pledgedSrcSizePlusOne) {
DEBUGLOG(4, "error : pledgedSrcSize = %u, while realSrcSize >= %u",
(U32)cctx->pledgedSrcSizePlusOne-1, (U32)cctx->consumedSrcSize);
return ERROR(srcSize_wrong);
}
}
return cSize + fhSize;
}
}