-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-118107: Fix zipimporter ZIP64 handling. #118108
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
702ece5
gh-118107: Fix zipimporter ZIP64 handling.
jsirois 923cdce
Move the struct import to the top level.
jsirois 6fb7668
Fix whitespace to match local convention for import comments.
jsirois 8d55e2f
Add a test for large files and fix fallout in zipimporter.
jsirois 86b23e3
Merge branch 'main' into fix-issue-118107
jsirois 13edef2
Update Misc/NEWS.d/next/Library/2024-04-19-09-28-43.gh-issue-118107.M…
jsirois d5df3fd
Merge branch 'main' into fix-issue-118107
jsirois 5d1f88d
Merge branch 'main' into fix-issue-118107
jsirois debba75
Speed testZip64LargeFile up by checking in test data.
gpshead 83bfe20
Kill ZIP_DEFLATED sparse trick and document.
jsirois b1bdd8f
Merge remote-tracking branch 'refs/remotes/upstream/main' into fix-is…
jsirois 00e30b2
Fix 80 cols and make generated test data reproducible, with added tes…
jsirois 3dc2325
Merge remote-tracking branch 'upstream/main' into fix-issue-118107
jsirois 801d0f4
Merge branch 'main' into fix-issue-118107
ambv 9a15380
Add test/zipimport_data to Makefile
encukou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -517,8 +517,9 @@ def _read_directory(archive): | |
num_extra_values = (len(extra_data) - 4) // 8 | ||
if num_extra_values > 3: | ||
raise ZipImportError(f"can't read header extra: {archive!r}", path=archive) | ||
values = struct.unpack_from(f"<{min(num_extra_values, 3)}Q", | ||
extra_data, offset=4) | ||
import struct | ||
jsirois marked this conversation as resolved.
Show resolved
Hide resolved
jsirois marked this conversation as resolved.
Show resolved
Hide resolved
|
||
values = list(struct.unpack_from(f"<{min(num_extra_values, 3)}Q", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new test caught the need for the list here. Prior to the fix you'd see:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another good catch! glad you added the test case! |
||
extra_data, offset=4)) | ||
|
||
# N.b. Here be dragons: the ordering of these is different than | ||
# the header fields, and it's really easy to get it wrong since | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2024-04-19-09-28-43.gh-issue-118107.Mdsr1J.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix :mod:`zipimport` reading of ZIP64 files with file entries that are too big or | ||
offset too far. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had introduced the decorator from
Lib/test/test_largefile.py
and then stumbled upon the resources support (-u
) that seems more widely used; so I went with it instead. The tests only run (and pass) with-ulargefile
: