Skip to content

gh-162129: Validate ZIP member comment length - #162149

Open
1cbyc wants to merge 1 commit into
python:mainfrom
1cbyc:1cbyc/162129-validate-member-comment
Open

1cbyc wants to merge 1 commit into
python:mainfrom
1cbyc:1cbyc/162129-validate-member-comment

Conversation

@1cbyc

@1cbyc 1cbyc commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #162129.

Reject ZIP member comments larger than the format's 65,535-byte field before member data is written. This prevents a late struct.error during close from leaving the archive without a central directory.

The regression covers the exact boundary, the rejected boundary-plus-one value, and confirms the archive remains readable after rejection.

Tests:

  • ./python -m test test_zipfile -m test_member_comment_too_long
  • ./python -m test test_zipfile
  • make patchcheck
  • git diff --cached --check

Co-authored-by: insisong [email protected]

@python-cla-bot

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

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.

zipfile: ZipInfo.comment exceeding 65535 bytes causes struct.error in ZipFile.close() without proper validation

1 participant