From: Elia Pinto Date: Wed, 18 Nov 2026 06:56:38 GMT Subject: [PATCH v2 4/4] pack-check: use size_t for the size passed to verify callbacks Message-ID: <00939c7f1b144fb9dbbc1745e60f7baa18217742.1794984184.git.gitter.spiros@gmail.com> In-Reply-To: verify_pack() in pack-check.c passes each object to a verify_fn callback (defined in pack.h) taking the object size as an "unsigned long", even though pack-check already handles it as a size_t. This signature is also replicated in struct odb_fsck_options (odb.h) and implemented by fsck_obj_buffer() in builtin/fsck.c. On platforms where "long" is 32 bits while size_t is 64, such as 64-bit Windows, running "git fsck" on packs with objects of 4GiB or more passes a truncated size to fsck_obj_buffer(), causing parse_object_buffer() and fsck_object() to inspect only a prefix. Use size_t for the size parameter in verify_fn, struct odb_fsck_options.object_cb, and fsck_obj_buffer(). parse_object_buffer() and fsck_object() themselves still take an "unsigned long"; until they are updated separately, they keep inspecting only a prefix. Triggering this requires processing objects of 4GiB or more on a platform where "long" is 32 bits while size_t is 64, so no test is added. Signed-off-by: Elia Pinto --- builtin/fsck.c | 2 +- odb.h | 2 +- pack.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index c4558efcf1..5849194686 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -392,7 +392,7 @@ static void check_connectivity(struct repository *repo) } static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, - unsigned long size, void *buffer, int *eaten, void *cb_data) + size_t size, void *buffer, int *eaten, void *cb_data) { struct repository *repo = cb_data; struct object *obj; diff --git a/odb.h b/odb.h index 857637f980..9d4ef41d9b 100644 --- a/odb.h +++ b/odb.h @@ -210,7 +210,7 @@ struct odb_fsck_options { enum odb_fsck_flags flags; int (*object_cb)(const struct object_id *oid, enum object_type type, - unsigned long size, void *buffer, int *eaten, void *cb_data); + size_t size, void *buffer, int *eaten, void *cb_data); void *object_payload; }; diff --git a/pack.h b/pack.h index 2f2ce97c11..acc72a9527 100644 --- a/pack.h +++ b/pack.h @@ -88,7 +88,7 @@ struct progress; /* Note, the data argument could be NULL if object type is blob */ typedef int (*verify_fn)(const struct object_id *oid, enum object_type type, - unsigned long size, + size_t size, void *buffer, int *eaten, void *fn_data); -- 2.53.0