packfile: widen `unpack_object_header_buffer()` to `size_t`

As part of the ongoing effort to replace `unsigned long` data types with
`size_t` wherever appropriate (mainly to fix all those problems on
Windows with objects larger than 4GB), let's also adjust the return type
and the type of the `len` parameter of this function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
main
Johannes Schindelin 2026-08-13 14:55:51 +00:00 committed by Junio C Hamano
parent b4b9a8cdbd
commit d50ac11724
4 changed files with 9 additions and 12 deletions

View File

@ -2259,8 +2259,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
int have_base = 0;
struct object_id base_ref;
struct object_entry *base_entry;
unsigned long used, used_0;
size_t avail;
size_t used, used_0, avail;
off_t ofs;
unsigned char *buf, c;
enum object_type type;
@ -2756,8 +2755,7 @@ size_t oe_get_size_slow(struct packing_data *pack,
struct pack_window *w_curs;
unsigned char *buf;
enum object_type type;
unsigned long used;
size_t avail, size;
size_t used, avail, size;

if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
size_t sz;

View File

@ -9,7 +9,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size_t len;

unpack_object_header_buffer((const unsigned char *)data,
(unsigned long)size, &type, &len);
size, &type, &len);

return 0;
}

View File

@ -1134,12 +1134,11 @@ out:
return ret;
}

unsigned long unpack_object_header_buffer(const unsigned char *buf,
unsigned long len, enum object_type *type, size_t *sizep)
size_t unpack_object_header_buffer(const unsigned char *buf, size_t len,
enum object_type *type, size_t *sizep)
{
unsigned shift;
size_t size, c;
unsigned long used = 0;
size_t size, c, used = 0;

c = buf[used++];
*type = (c >> 4) & 7;
@ -1228,8 +1227,7 @@ int unpack_object_header(struct packed_git *p,
size_t *sizep)
{
unsigned char *base;
size_t left;
unsigned long used;
size_t left, used;
enum object_type type;

/* use_pack() assures us we have [base, base + 20) available

View File

@ -458,7 +458,8 @@ off_t find_pack_entry_one(const struct object_id *oid, struct packed_git *);
int is_pack_valid(struct packed_git *);
void *unpack_entry(struct repository *r, struct packed_git *, off_t,
enum object_type *, size_t *);
unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *sizep);
size_t unpack_object_header_buffer(const unsigned char *buf, size_t len,
enum object_type *type, size_t *sizep);
size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);
off_t get_delta_base(struct packed_git *p, struct pack_window **w_curs,