Git development
 help / color / mirror / Atom feed
From: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	Kristofer Karlsson <krka@spotify.com>,
	Kristofer Karlsson <krka@spotify.com>
Subject: [PATCH 1/2] unpack-objects: pass the size of a streamed blob as size_t
Date: Fri, 06 Nov 2026 12:51:15 +0000	[thread overview]
Message-ID: <789bb9bca7f4a1c97cfd7a1062d80698cd3e11fc.1793969476.git.gitgitgadget@gmail.com> (raw)
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


  reply	other threads:[~2026-11-06 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 12:51 [PATCH 0/2] t5608: assert that the packs involved really are that large Kristofer Karlsson via GitGitGadget
2026-11-06 12:51 ` Kristofer Karlsson via GitGitGadget [this message]
2026-11-06 12:51 ` [PATCH 2/2] " Kristofer Karlsson via GitGitGadget
2026-11-06 14:54   ` Patrick Steinhardt
2026-11-06 15:12     ` Kristofer Karlsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=789bb9bca7f4a1c97cfd7a1062d80698cd3e11fc.1793969476.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=krka@spotify.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox