Skip to content

Commit f887870

Browse files
Zombor Mátéqkaiser
authored andcommitted
fix(handlers): improve ZIP handler to support known indicators of ZIP64 usage
The implementation of the ZIP handler only checked one of the known indicators of `ZIP64` usage. The missing logic resulted in the code getting stuck in an infinite loop as it couldn't detect the end of the records correctly. Documentation for known indicators can be found at: https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.1.TXT
1 parent 29d5ed6 commit f887870

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

unblob/handlers/archive/zip.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ def has_encrypted_files(
101101

102102
@staticmethod
103103
def is_zip64_eocd(end_of_central_directory: Instance):
104-
return end_of_central_directory.offset_of_cd == 0xFFFFFFFF
104+
# see https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.1.TXT section J
105+
return (
106+
end_of_central_directory.disk_number == 0xFFFF
107+
or end_of_central_directory.disk_number_with_cd == 0xFFFF
108+
or end_of_central_directory.disk_entries == 0xFFFF
109+
or end_of_central_directory.total_entries == 0xFFFF
110+
or end_of_central_directory.central_directory_size == 0xFFFFFFFF
111+
or end_of_central_directory.offset_of_cd == 0xFFFFFFFF
112+
)
105113

106114
def _parse_zip64(self, file: File, start_offset: int, offset: int) -> int:
107115
file.seek(start_offset, io.SEEK_SET)

0 commit comments

Comments
 (0)