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

[PATCH 1/2] unpack-objects: pass the size of a streamed blob as size_t

From
Kristofer Karlsson via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 6, 2026, 12:51 UTC
Message-ID
<789bb9bca7f4a1c97cfd7a1062d80698cd3e11fc.1793969476.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2299.git.1793969476.gitgitgadget@gmail.com>
From: Kristofer Karlsson <krka@spotify.com>

Since f2063855fb (index-pack, unpack-objects: use size_t for object size, 2026-05-08), unpack_one() decodes the size of an object into a size_t. But stream_blob(), which is used for blobs larger than core.bigFileThreshold, still takes that size as "unsigned long". Where that type is only 32 bits wide, such as on Windows, the size of a blob larger than 4GB is truncated, and writing the object fails:

  fatal: write stream object 4294967304 != 8

This was found by the next commit, which makes t5608 actually exercise the unpack-objects path for a >4GB blob.

Take the size as size_t instead. The struct odb_stream it is stored in already uses size_t, as does the rest of the path that writes the loose object.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
---
 builtin/unpack-objects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 351948724a..d2f25bed49 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -386,7 +386,7 @@ static ssize_t zlib_stream_read(struct odb_stream *in_stream,
 	return buf_len - zstream->avail_out;
 }
 
-static void stream_blob(unsigned long size, unsigned nr)
+static void stream_blob(size_t size, unsigned nr)
 {
 	git_zstream zstream = { 0 };
 	struct zlib_stream in_stream = {
-- 
gitgitgadget
Previous: Kristofer Karlsson via GitGitGadgetNext: Kristofer Karlsson via GitGitGadget
Message 2 of 5 in “t5608: assert that the packs involved really are that large”
  1. 0/2 t5608: assert that the packs involved really are that largeKristofer Karlsson via GitGitGadget, Nov 6, 2026
  2. 1/2 unpack-objects: pass the size of a streamed blob as size_tKristofer Karlsson via GitGitGadget, Nov 6, 2026
  3. 2/2 t5608: assert that the packs involved really are that largeKristofer Karlsson via GitGitGadget, Nov 6, 2026
  4. Patrick SteinhardtNov 6, 2026
  5. Kristofer KarlssonNov 6, 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.