Skip to content

Commit f1f18d9

Browse files
committed
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.
1 parent c040df9 commit f1f18d9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

unblob/handlers/archive/cpio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ def valid_checksum(self, header, start_offset: int) -> bool:
368368

369369
for chunk in iterate_file(self.file, start_offset, file_size):
370370
calculated_checksum += sum(bytearray(chunk))
371-
372-
return header_checksum == calculated_checksum
371+
return header_checksum == calculated_checksum & 0xFF_FF_FF_FF
373372

374373

375374
class _CPIOExtractorBase(Extractor):

0 commit comments

Comments
 (0)