Repository navigation
fix: raw_copy_file wrote two ZIP64 extra fields when the copy needed its own - #1349
Merged
Pr0methean merged 1 commit intoNov 23, 2026
Merged
Conversation
…its own raw_copy_options copied the source's ZIP64 extended information field (0x0001) into the new entry's options. When the copy's sizes or offset need ZIP64, the writer adds its own field too, so the entry had two, and ZipArchive failed on the result with "Invalid local file header". Skip the source's field; the writer computes the copy's from its own sizes and offset. Fixes zip-rs#1348
Pr0methean
approved these changes
Nov 23, 2026
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.
Fixes #1348.
raw_copy_optionscopied the source entry's ZIP64 extended information field (0x0001) into the new entry's options as raw bytes. When the copy's sizes or local header offset need ZIP64, the writer adds its own field too, so the entry ends up with two.replace_zip64_extra_fieldalready prevents duplicates amongextra_fields.inner, but the copied field arrives throughadd_extra_fieldand isn't seen there.ZipArchivethen fails on the copy withInvalid local file header. In practice, raw-copying the entries of any archive over 4 GiB produced an unreadable archive.Fix: skip
ExtraField::Zip64ExtendedInformationinraw_copy_options, as the extended timestamp is already skipped. The writer computes the copy's ZIP64 field from its own sizes and offset.Test:
tests/raw_copy_zip64.rsraw-copies an entry whose central header has a ZIP64 field (large_file(true)) into a writer positioned at 4 GiB. The writer is an in-memoryRead + Write + Seekthat reports the first 4 GiB as zeros without storing them, so the test runs in milliseconds and allocates only a few KB. It checks each copied entry has one ZIP64 field and reads back. It fails on master withInvalid local file headerand passes with the fix. I also checked the fix against a real 4.3 GB archive (a stored 4 GiB + 16 MiB entry, then one past the 4 GiB offset): every entry's name, method, CRC, sizes and raw bytes are kept, and the ZIP64 end records are written.Checks run locally (macOS, stable 1.100.0):
cargo fmt --check --all: okcargo testwith default features,--no-default-featuresand--all-features: 576 / 486 / 636 passed, 0 failedcargo clippy --all-targetswith default features and--all-features: clean. With--no-default-featuresthere's onefield_reassign_with_defaulterror insrc/extra_fields/extra_field.rs:376that's already on master with this clippy; this PR doesn't touch it.Maintainer edits are allowed on the branch.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.