minilzlib: fix support for non-CRC32 checksum types

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-02-06 16:33:46 +09:00
parent 61e2c36ef5
commit 93bad96311

View file

@ -232,6 +232,8 @@ XzDecodeStreamFooter (
//
if ((streamFooter->u.Flags != 0) &&
((streamFooter->u.s.CheckType != XzCheckTypeCrc32) &&
(streamFooter->u.s.CheckType != XzCheckTypeCrc64) &&
(streamFooter->u.s.CheckType != XzCheckTypeSha2) &&
(streamFooter->u.s.CheckType != XzCheckTypeNone)))
{
return false;
@ -350,6 +352,8 @@ XzDecodeStreamHeader (
//
if ((streamHeader->u.Flags != 0) &&
((streamHeader->u.s.CheckType != XzCheckTypeCrc32) &&
(streamHeader->u.s.CheckType != XzCheckTypeCrc64) &&
(streamHeader->u.s.CheckType != XzCheckTypeSha2) &&
(streamHeader->u.s.CheckType != XzCheckTypeNone)))
{
return false;
@ -358,7 +362,13 @@ XzDecodeStreamHeader (
//
// Remember that a checksum might come at the end of the block later
//
Container.ChecksumSize = streamHeader->u.s.CheckType * 4;
if (streamHeader->u.s.CheckType == 0)
{
Container.ChecksumSize = 0;
} else {
Container.ChecksumSize = 4 << ((streamHeader->u.s.CheckType - 1) / 3);
}
#endif
#ifdef MINLZ_INTEGRITY_CHECKS
//