Skip to content

fix: keep extended timestamp and NTFS extra fields in raw copies - #1293

Merged
Pr0methean merged 8 commits into
zip-rs:masterfrom
compiler-segfault:fix/raw-copy-keep-extra-fields
Nov 15, 2026
Merged

Pr0methean merged 8 commits into
zip-rs:masterfrom
compiler-segfault:fix/raw-copy-keep-extra-fields

Conversation

@compiler-segfault

@compiler-segfault compiler-segfault commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1285.

ExtraField::size and ExtraField::write had no arm for the extended timestamp (0x5455)
and the NTFS file times (0x000a), so raw_copy_options serialized them to nothing and
raw_copy_file silently dropped them. A tool that builds an archive by raw-copying entries
then keeps only the DOS date-time from the local header, which is local time with
two-second resolution and shifts when the archive is restored in another time zone.

Both fields are written again:

  • Ntfs is serialized as the 32-byte file-times attribute it was parsed from: the reserved
    field, the 0x0001 attribute tag, an attribute size of 24, and the modification, access and
    creation times.
  • ExtendedTimestamp writes the flags byte and the timestamps it holds. The central header
    only stores the modification time, so the central form advertises only that bit and
    carries only that value; the local form keeps the access and creation times when they are
    known. Flags that do not match the stored data would make the field unreadable, so they
    are derived from what is actually written.

Tests: tests/raw_copy_extra_fields.rs builds an archive with both fields, raw-copies it,
and checks that the copy still has the same 0x5455 modification time and the same 0x000a
file times, and that the copied entry is still readable. Two unit tests cover the local and
central serialization of the extended timestamp.

cargo test (default features and --no-default-features) and cargo clippy --all-targets
pass; --all-features needs cmake for libz-sys here, which this environment lacks.

As the template asks: the branch is based on master at dee278bc240e, so it needs no
rebase right now, and I have invited you as a collaborator on compiler-segfault/zip2 so
you can push conflict fixes to the branch.

I used an AI assistant (Claude) to help write this patch.

`ExtraField::size` and `ExtraField::write` had no arm for the extended
timestamp (0x5455) and the NTFS file times (0x000a), so `raw_copy_options`
serialized them to nothing and `raw_copy_file` silently dropped them. A copy
then only keeps the DOS date-time from the local header, which is local time
with two-second resolution.

Write both fields again: the NTFS attribute is 32 bytes, and the extended
timestamp advertises only the timestamps it stores, since the central header
keeps the modification time alone.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 06:10

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Comment thread src/extra_fields/extended_timestamp.rs Resolved
Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 06:03

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 06:04

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Pr0methean
Pr0methean previously approved these changes Nov 14, 2026
@Pr0methean
Pr0methean enabled auto-merge November 14, 2026 06:04
Copilot AI balanced review requested due to automatic review settings November 14, 2026 06:07

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

auto-merge was automatically disabled November 14, 2026 12:15

Head branch was pushed to by a user without write access

Copilot AI balanced review requested due to automatic review settings November 14, 2026 12:15

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@compiler-segfault

Copy link
Copy Markdown
Contributor Author

Merged current master (b808cbe) to clear the conflict; cargo test and cargo fmt --all -- --check pass, so the branch is mergeable again. The full_size change you suggested is kept (mem::size_of::<u32>() * self.time_count(is_local_header)).

Signed-off-by: n4n5 <git@n4n5.dev>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 12:54

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Signed-off-by: n4n5 <git@n4n5.dev>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 12:56

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI balanced review requested due to automatic review settings November 15, 2026 01:19

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Pr0methean
Pr0methean enabled auto-merge November 15, 2026 01:19
@Pr0methean
Pr0methean added this pull request to the merge queue Nov 15, 2026
Merged via the queue into zip-rs:master with commit af66d9c Nov 15, 2026
127 of 128 checks passed
@Pr0methean
Pr0methean deleted the fix/raw-copy-keep-extra-fields branch November 15, 2026 03:00
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.

raw_copy_file silently drops the extended timestamp (0x5455) extra field

5 participants