From f1f18d94b9a51a1c015152941c2dd6079cde1549 Mon Sep 17 00:00:00 2001 From: Marton ILLES Date: Fri, 10 Nov 2023 18:56:55 +0100 Subject: [PATCH] fix(cpio): fixed checksum calculation to handle 4 byte overflows Checksum stored in the header is always 4 bytes in length, so when we calculate the checksum, we need to sure that we only consider the 4bytes part and ommit the overflown part. --- unblob/handlers/archive/cpio.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unblob/handlers/archive/cpio.py b/unblob/handlers/archive/cpio.py index 14128cb79f..43dc2836a4 100644 --- a/unblob/handlers/archive/cpio.py +++ b/unblob/handlers/archive/cpio.py @@ -368,8 +368,7 @@ def valid_checksum(self, header, start_offset: int) -> bool: for chunk in iterate_file(self.file, start_offset, file_size): calculated_checksum += sum(bytearray(chunk)) - - return header_checksum == calculated_checksum + return header_checksum == calculated_checksum & 0xFF_FF_FF_FF class _CPIOExtractorBase(Extractor):