-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-72680: Fix false positives when using zipfile.is_zipfile() #134250
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Improve Zip file validation in :func:`zipfile.is_zipfile`. | ||
|
|
||
| Before this change :func:`zipfile.is_zipfile` only checked the End Central Directory | ||
| signature. If the signature could be found in the last 64k of the file, | ||
| success! This produced false positives on any file with ``'PK\x05\x06'`` in the | ||
| last 64k of the file - including PDFs and PNGs. | ||
|
|
||
| This is now corrected by actually validating the Central Directory location | ||
| and size based on the information provided by the End of Central Directory | ||
| along with verifying the Central Directory signature of the first entry. | ||
|
|
||
| This should be sufficient for the vast number of Zip files with fewer | ||
| false positives. | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.