Repository navigation
fix: file-header length check in central directory neglected file comment, and in local header was too stringent by one byte - #1340
Conversation
|
Warning Amazon Q Developer for GitHub: end of support On January 30, 2027, AWS will discontinue support for the Amazon Q Developer for GitHub App. New app installations will no longer be available starting November 18, 2026. For capabilities similar to the Amazon Q Developer for GitHub App, explore Kiro and the Kiro GitHub App. For more information about the end of support, see Amazon Q Developer end-of-support announcement on the AWS DevOps Blog. |
There was a problem hiding this comment.
This PR fixes two related issues in start_entry: including the file comment in the local entry length check, and relaxing the boundary condition from >= to >.
The off-by-one fix (> instead of >=) is correct: u16::MAX (65535) bytes is a valid local header size since it still fits in the u16 extra_field_length field.
However, the file comment inclusion in entry_len is incorrect. Per the ZIP specification (APPNOTE 4.3.2), the local file header has no comment field at all — the comment is a central directory-only concept (APPNOTE 4.3.12). Adding file_comment_raw.len() to entry_len artificially limits entries whose local headers would fit fine, solely because they have a long central directory comment. The same issue propagates to the fuzz harness where max_path_len_for is similarly adjusted.
Additional note: The PR title Fix: file length check neglected file comment, but was also too stringent by one byte does not conform to Conventional Commits — the type prefix must be lowercase (fix:, not Fix:), as required by the project's contributing guidelines.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
…_length + file_comment_length separately
ByGh00st
left a comment
There was a problem hiding this comment.
The off-by-one fix in start_entry (>= -> >) and the updated tests/zip_extra_field.rs look right (u16::MAX = 65535 fits in a u16 and is strictly less than 64 KiB).
A few issues on the central directory side though: the new extra_field_length + file_comment_length check in write_central_directory_header doesn't include file_name_raw.len() or the 46-byte central header (Magic + ZipCentralEntryBlock), so it sits halfway between enforcing individual u16 field limits and enforcing APPNOTE 4.4.10's 65535-byte combined record limit. Left inline details below, plus a stale comment in fuzz/write/src/main.rs and missing tests for the new check and FileOptions::file_comment().
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.