Skip to content

test(fuzz): treat shrinking central-directory extra fields as non-streamable - #1306

Merged
Pr0methean merged 2 commits into
zip-rs:masterfrom
ByGh00st:fix/fuzz-write-non-streamable-reopen
Nov 15, 2026
Merged

Pr0methean merged 2 commits into
zip-rs:masterfrom
ByGh00st:fix/fuzz-write-non-streamable-reopen

Conversation

@ByGh00st

@ByGh00st ByGh00st commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1302 and #1304 per @Pr0methean's direction ("Treat them as non-streamable"), fixing the fuzz_write CI failures in run 43566959380 and unblocking v9.6.0 (#1297).

Cause

When ZipWriter::new_append reopens an archive and rewrites the central directory at dir_start (#1302), any custom extra field whose central-directory representation shrinks on round-trip causes finalize() (footer_end < stream_end) to zero central_start and relocate the footer to EOF:

  • 0x5455 (ExtendedTimestamp) when data.len() != 1 and (data.len() != 5 || data[0] & 1 == 0) (re-serializes as 1 or 5 bytes).
  • 0xa11e (DataStreamAlignment) and 0xd935 (AndroidZipAlignment), which ExtraFields::central_extra_fields omits from the rewritten central directory.
  • 0x0001 (Zip64ExtendedInfo), which replace_zip64_extra_field strips/replaces.

Changes

  • Expose read-only FileOptions::extra_fields(&self) -> &[CustomExtraField] (src/write/options.rs).
  • Mark FileOperation::is_streamable as false when central_extra_fields_shrink_on_reopen(options) is true (fuzz/write/src/main.rs).
  • Add reopen-extended-timestamp-extra-field-shrinks.bin regression input and unit test shrinking_central_extra_fields_mark_operation_non_streamable.

/cc @Pr0methean @ychampion


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are correct and well-targeted. The root cause analysis in the PR description is accurate, and the fix is properly scoped to the fuzz harness.

src/write/options.rs: The new extra_fields(&self) -> &[CustomExtraField] accessor is a clean, minimal public API addition needed to let the fuzz harness inspect extra fields without reaching into private internals.

fuzz/write/src/main.rs: central_extra_fields_shrink_on_reopen correctly identifies all three categories of shrinking central-directory extra fields documented in the PR (alignment fields, ZIP64, and ExtendedTimestamp). The ExtendedTimestamp branch logic at line 221 (field.data.len() != 1 && (field.data.len() != 5 || field.data[0] & 1 == 0)) correctly mirrors the re-serialization behaviour of parse_central_header. All test vector cases in shrinking_central_extra_fields_mark_operation_non_streamable are consistent with the logic.

No blocking defects found. The PR is ready to merge.


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.

@Pr0methean Pr0methean changed the title fix(fuzz): treat shrinking central-directory extra fields as non-streamable test(fuzz): treat shrinking central-directory extra fields as non-streamable Nov 15, 2026
@Pr0methean
Pr0methean enabled auto-merge November 15, 2026 00:24
@Pr0methean
Pr0methean added this pull request to the merge queue Nov 15, 2026
Merged via the queue into zip-rs:master with commit 8b9ae04 Nov 15, 2026
127 of 128 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants