Skip to content

archive: preserve 4GiB+ entry sizes on LLP64 - #6427

Open
i80487 wants to merge 3 commits into
git-for-windows:mainfrom
i80487:copilot/fix-zip-entry-size-truncation
Open

i80487 wants to merge 3 commits into
git-for-windows:mainfrom
i80487:copilot/fix-zip-entry-size-truncation

Conversation

@i80487

@i80487 i80487 commented Sep 21, 2026

Copy link
Copy Markdown

Note: This PR was created as part of a test of GitHub Copilot agents. I believe the proposed changes are relevant and consistent, but I don’t have enough experience with the git-for-windows source code to evaluate them properly.

I was unable to verify that these changes work correctly using the test script ‎t/t5005-archive-large-files.sh, because it appears that the GIT_TEST_LONG=true option and the SIZE_T_IS_64BIT prerequisite must be enabled, and I don’t know how to configure this in GitHub CI/CD.

Feel free to modify, defer, or reject this PR.

Details:

git archive still carried unsigned long size plumbing in both zip and tar paths, which truncates 4GiB+ entry sizes on LLP64 Windows before Zip64/PAX logic can trigger. As a result, large entries could be archived with silently wrapped sizes even though the surrounding format support already handled 64-bit lengths.

  • Common archive callback plumbing

    • Widen write_archive_entry_fn_t and the write_archive_entries() call chain from unsigned long to size_t.
    • Update indirect callers so large blob sizes are forwarded without narrowing before they reach the backend writers.
  • Zip backend: make Zip64 decisions from real sizes

    • Convert ZIP entry size and compressed-size state to size_t.
    • Keep CRC as uint32_t; do not conflate checksum width with payload size width.
    • Clamp 32-bit header fields only at the final non-Zip64 write sites, after the Zip64 decision is made.
    • Add a chunked CRC helper so in-memory CRC computation remains correct for size_t-sized buffers.
  • Tar backend: keep tar/PAX consistent with widened sizes

    • Update tar entry and extended-header size handling to size_t.
    • Preserve large regular-file sizes through PAX extended-header generation instead of narrowing them in the callback layer.
    • Adjust buffered tar write helpers to use size_t consistently.
  • Regression coverage

    • Add a new expensive SIZE_T_IS_64BIT archive test that creates a real 4GiB file, commits it, archives it, and verifies the reported entry size in both zip and tar output.
    • Register the test in t/meson.build.

Copilot AI and others added 3 commits September 19, 2026 06:37
Co-authored-by: i80487 <222595226+i80487@users.noreply.github.com>
Co-authored-by: i80487 <222595226+i80487@users.noreply.github.com>

This branch has not been deployed

No deployments
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