From 9f6c60e20c44ecf3645916f8b6add5f53e501f0f Mon Sep 17 00:00:00 2001 From: Quentin Kaiser Date: Thu, 13 Jun 2024 16:24:57 +0200 Subject: [PATCH] fix(zip): handle ZIP64 files missing indicators of ZIP64 (fix). We should still raise an exception if offset is not bound, otherwise we have an unhandled 'UnboundLocalError'. --- unblob/handlers/archive/zip.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unblob/handlers/archive/zip.py b/unblob/handlers/archive/zip.py index 0c233e1548..53db5307fc 100644 --- a/unblob/handlers/archive/zip.py +++ b/unblob/handlers/archive/zip.py @@ -167,6 +167,7 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk] has_encrypted_files = False file.seek(start_offset, io.SEEK_SET) + offset = None for offset in iterate_patterns( file, struct.pack(" Optional[ValidChunk] if offset == end_of_central_directory_offset: break else: - # if we can't find 32bit ZIP EOCD, we fall back to ZIP64 + if offset is None: + raise InvalidInputFormat("Missing EOCD record header in ZIP chunk.") + # if we can't find a valid 32bit ZIP EOCD, we fall back to ZIP64 end_of_central_directory = self._parse_zip64(file, start_offset, offset) has_encrypted_files = self.has_encrypted_files(