git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] archive, apply: do not truncate files of 4GiB or more

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Nov 1, 2026, 09:19 UTC
Message-ID
<cover.1793524457.git.gitter.spiros@gmail.com>

Two more cases where, on platforms where "long" is 32 bits but size_t is 64 bits (64-bit Windows), a file of 4GiB or more is written truncated or corrupt without any error.

- 1/2 archive: tar and zip of a file written by streaming come out
  corrupt.
- 2/2 apply: the file being patched is written truncated with exit 0
  (also with --index and git am).

No new tests; both were verified by simulating the truncation at 16 bits, as described in the messages.

Regarding t5004, the existing test "zip archive with files bigger than 4GB" has been excluded where "long" is 32 bits (LONG_IS_64BIT) since 2017, because back then the object database couldn't read objects that large. Today on 64-bit Windows it can, and with this series zip works too. Thus, the guard could become SIZE_T_IS_64BIT to enable a real test on Windows. Since I haven't run it on Windows, I'm offering this as a follow-up or asking reviewers for an opinion.

With this series, the search for these truncations is finished. The remaining warnings are not reachable: a 4GiB index, sizes bounded by config or by the format, commits over 4GiB that already die.

It doesn't depend on the other series in flight and merges cleanly with them. Based on master 50fe5cc63f.

Elia Pinto (2):
  archive: use size_t for the size of archive entries
  apply: use size_t for the size of the result written out
 apply.c       |  8 ++++----
 archive-tar.c | 10 +++++-----
 archive-zip.c | 16 ++++++++--------
 archive.h     |  2 +-
 4 files changed, 18 insertions(+), 18 deletions(-)
base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7
-- 
2.53.0
Next: Elia Pinto
Message 1 of 6 in “archive, apply: do not truncate files of 4GiB or more”
  1. 0/2 archive, apply: do not truncate files of 4GiB or moreElia Pinto, Nov 1, 2026
  2. 1/2 archive: use size_t for the size of archive entriesElia Pinto, Nov 1, 2026
  3. 2/2 apply: use size_t for the size of the result written outElia Pinto, Nov 1, 2026
  4. Elia PintoNov 19, 2026
  5. Patrick SteinhardtNov 19, 2026
  6. Elia PintoNov 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.