gh-156539: Validate duplicate ZIP members individually in testzip - #156540
Open
lpyu001 wants to merge 1 commit into
Open
gh-156539: Validate duplicate ZIP members individually in testzip#156540lpyu001 wants to merge 1 commit into
lpyu001 wants to merge 1 commit into
Conversation
Pass each ZipInfo directly to open() so testzip() does not resolve duplicate filenames to the last matching member. Co-authored-by: lipengyu <lipengyu@kylinos.cn>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix
ZipFile.testzip()to pass eachZipInfoobject directly toopen()instead of reopening the member by filename.When an archive contains duplicate filenames, filename-based lookup resolves to the last matching entry. As a result,
testzip()can iterate over an earlierZipInfobut actually reopen and validate a later duplicate, allowing corruption in the earlier member to go undetected.Passing the
ZipInfodirectly preserves the identity of the member being iterated and ensures that every entry infilelistis validated individually.This also avoids an unnecessary filename-to-
ZipInfolookup throughNameToInfoand makes the implementation better match the existingZipFile.open()API, which already acceptsZipInfoobjects specifically to disambiguate duplicate members.ZipFile.testzip()Skips Earlier Duplicate Members #156539