Skip to content

gh-156539: Validate duplicate ZIP members individually in testzip - #156540

Open
lpyu001 wants to merge 1 commit into
python:mainfrom
lpyu001:fix-testzip-bug-156539
Open

gh-156539: Validate duplicate ZIP members individually in testzip#156540
lpyu001 wants to merge 1 commit into
python:mainfrom
lpyu001:fix-testzip-bug-156539

Conversation

@lpyu001

@lpyu001 lpyu001 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Fix ZipFile.testzip() to pass each ZipInfo object directly to open() 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 earlier ZipInfo but actually reopen and validate a later duplicate, allowing corruption in the earlier member to go undetected.

Passing the ZipInfo directly preserves the identity of the member being iterated and ensures that every entry in filelist is validated individually.

This also avoids an unnecessary filename-to-ZipInfo lookup through NameToInfo and makes the implementation better match the existing ZipFile.open() API, which already accepts ZipInfo objects specifically to disambiguate duplicate members.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant