-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zipfile generates Zipfile error in zip with 0 total number of disk in Zip64 end of central directory locator #66300
Comments
I've got a zip file with a Zip64 end of central directory locator in which:
According to the test line 176 in zipfile.py this fails: I believe the test should be changed to |
Do you know what tool created the zip file? I can't find anything in the spec (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT ) to say whether 0 is a valid value for the number of disks. |
I found source code for some other projects handling the same data. They all seem to agree that it should be 1:
So I think you've got an invalid zip file. If it's otherwise valid, there might be a case for Python tolerating that particular mistake. But it's probably better to fix whatever is making the incorrect zip file, because other tools are also going to reject it. |
Hi, On Mon, Mar 12, 2018 at 5:08 AM, Thomas Kluyver <report@bugs.python.org>
|
If every Windows 7 computer is generating zipfiles which are invalid in this way, that would be a pretty strong argument for Python (and other tools) to accept it. But if that was the case, I would also expect that there would be many more issues about it. Are the files you're compressing large (multi-GB)? Python only uses the zip64 format when the files are too big for the older zip format; maybe Windows is doing the same. Even in that case, I'm still surprised that more people don't hit it. |
Yes these were pretty large zip 30 to 60Gb with thousands of small files in On Mon, Mar 12, 2018 at 9:01 AM, Thomas Kluyver <report@bugs.python.org>
|
I would second this PR. The Win32 API that creates ZIP64 files produces ZIP64 files with the "diskno" as 0 and "disks" as 0 (instead of "1" as indicated by the spec). |
I also ran across this issue today, where the 'disks' value in a Zip file is 0. I'm trying to find out what software was used to create them, but it's quite plausible that it's Windows as Ramsey Kant suggests. So I think this fix should get applied to 3.8 and 3.7. Would it help if I produced a patch? The PKWare Zip specification that takluyver links above has been updated -- it now has an April 29th updated -- but none of the changes are relevant to this. Interestingly, the 'ditto' command on MacOS X (which can also unpack zip files) doesn't complain about the disk number either. I was unable to figure out where the source code for ditto is; I couldn't find it on opensource.apple.com. |
Oh, I missed that there was already a patch. BTW, I found two dissections of zip files that also show disk numbers of 0: the one at https://rzymek.github.io/post/excel-zip64/ is exploring an Excel Zip issue, and the forensic tutorial at https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html is discussing the format. |
@Guillaume.Carre, thank you for the report and @fran6co, thank you for the contribution. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: