Skip to content

Commit 4d2ba1e

Browse files
author
János Kukovecz
authored
Merge pull request #876 from onekey-sec/fix-unbound-offset
fix(zip): handle ZIP64 files missing indicators of ZIP64
2 parents 63a8408 + 9f6c60e commit 4d2ba1e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

unblob/handlers/archive/zip.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]
167167
has_encrypted_files = False
168168
file.seek(start_offset, io.SEEK_SET)
169169

170+
offset = None
170171
for offset in iterate_patterns(
171172
file, struct.pack("<I", self.EOCD_RECORD_HEADER)
172173
):
@@ -188,7 +189,9 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]
188189
if offset == end_of_central_directory_offset:
189190
break
190191
else:
191-
# if we can't find 32bit ZIP EOCD, we fall back to ZIP64
192+
if offset is None:
193+
raise InvalidInputFormat("Missing EOCD record header in ZIP chunk.")
194+
# if we can't find a valid 32bit ZIP EOCD, we fall back to ZIP64
192195
end_of_central_directory = self._parse_zip64(file, start_offset, offset)
193196

194197
has_encrypted_files = self.has_encrypted_files(

0 commit comments

Comments
 (0)