Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static const char index_pack_usage[] =

struct object_entry {
struct pack_idx_entry idx;
unsigned long size;
size_t size; // should be 64bit as size can be >4GB
unsigned char hdr_size;
signed char type;
signed char real_type;
Expand Down Expand Up @@ -469,7 +469,7 @@ static int is_delta_type(enum object_type type)
return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
}

static void *unpack_entry_data(off_t offset, unsigned long size,
static void *unpack_entry_data(off_t offset, size_t size,
enum object_type type, struct object_id *oid)
{
static char fixed_buf[8192];
Expand Down Expand Up @@ -524,7 +524,8 @@ static void *unpack_raw_entry(struct object_entry *obj,
struct object_id *oid)
{
unsigned char *p;
unsigned long size, c;
size_t size; // need to be 64 bit as size can be > 4GB
unsigned long c;
off_t base_offset;
unsigned shift;
void *data;
Expand All @@ -542,7 +543,8 @@ static void *unpack_raw_entry(struct object_entry *obj,
p = fill(1);
c = *p;
use(1);
size += (c & 0x7f) << shift;
// need shift in 64 bit space , as if shift > 32 is valid case in 4GB+ size objects
size += (size_t)(c & 0x7f) << shift;
shift += 7;
}
obj->size = size;
Expand Down
6 changes: 4 additions & 2 deletions builtin/unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ static void unpack_one(unsigned nr)
{
unsigned shift;
unsigned char *pack;
unsigned long size, c;
size_t size;
unsigned long c;
enum object_type type;

obj_list[nr].offset = consumed_bytes;
Expand All @@ -548,7 +549,8 @@ static void unpack_one(unsigned nr)
pack = fill(1);
c = *pack;
use(1);
size += (c & 0x7f) << shift;
// need shift in 64 bit space , as if shift > 32 is valid case in 4GB+ size objects
size += (size_t)(c & 0x7f) << shift;
shift += 7;
}

Expand Down
Loading