"Zip64 end of central directory record" may have additional data in the "zip64 extensible data sector" field.
In that case, zipfile should use offset from "Zip64 end of central directory locator".
Now it's read but ignored.
defrun_test():
withzipfile.ZipFile("file-with-extended-zip64eocd-record.zip", allowZip64=True) asspecial_file: # This failsprint("success")
Problem lies in following code:
sig, diskno, reloff, disks=struct.unpack(structEndArchive64Locator, data)
ifsig!=stringEndArchive64Locator:
returnendrecifdiskno!=0ordisks>1:
raiseBadZipFile("zipfiles that span multiple disks are not supported")
# Assume no 'zip64 extensible data'fpin.seek(offset-sizeEndCentDir64Locator-sizeEndCentDir64, 2)
data=fpin.read(sizeEndCentDir64)
While it should be:
sig, diskno, reloff, disks=struct.unpack(structEndArchive64Locator, data)
ifsig!=stringEndArchive64Locator:
returnendrecifdiskno!=0ordisks>1:
raiseBadZipFile("zipfiles that span multiple disks are not supported")
fpin.seek(reloff, 0)
data=fpin.read(sizeEndCentDir64)
@serhiy-storchaka I'm reasonably happy with that PR, but it lacks tests. We currently can't create a zip with such data using just zipfile, so there's a little chicken-egg situation.
Activity
VladRassokhin commented on Nov 14, 2024
Hex output of the end of such file:
VladRassokhin commented on Nov 14, 2024
I can submit MR in a couple of days. Seems I've found a solution.
VladRassokhin commented on Nov 14, 2024
Here's a python script which is able to generate a zip64 archive with some data in the zip64 end-of-archive record:
https://gist.github.com/VladRassokhin/9299bb8fbe3169b96e7bc31f91553815
I've copied and adjusted zipfile.ZipFile._write_end_record
Properly read zip64 archives with non-empty zip64 extensible data sec…
thatch commented on May 20, 2025
@serhiy-storchaka I'm reasonably happy with that PR, but it lacks tests. We currently can't create a zip with such data using just zipfile, so there's a little chicken-egg situation.
danifus commented on Apr 27, 2026
Fixed by: #139702