File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ static const char index_pack_usage[] =
3737
3838struct object_entry {
3939 struct pack_idx_entry idx ;
40- unsigned long size ;
40+ size_t size ; // should be 64bit as size can be >4GB
4141 unsigned char hdr_size ;
4242 signed char type ;
4343 signed char real_type ;
@@ -469,7 +469,7 @@ static int is_delta_type(enum object_type type)
469469 return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA );
470470}
471471
472- static void * unpack_entry_data (off_t offset , unsigned long size ,
472+ static void * unpack_entry_data (off_t offset , size_t size ,
473473 enum object_type type , struct object_id * oid )
474474{
475475 static char fixed_buf [8192 ];
@@ -524,7 +524,8 @@ static void *unpack_raw_entry(struct object_entry *obj,
524524 struct object_id * oid )
525525{
526526 unsigned char * p ;
527- unsigned long size , c ;
527+ size_t size ; // need to be 64 bit as size can be > 4GB
528+ unsigned long c ;
528529 off_t base_offset ;
529530 unsigned shift ;
530531 void * data ;
@@ -542,7 +543,8 @@ static void *unpack_raw_entry(struct object_entry *obj,
542543 p = fill (1 );
543544 c = * p ;
544545 use (1 );
545- size += (c & 0x7f ) << shift ;
546+ // need shift in 64 bit space , as if shift > 32 is valid case in 4GB+ size objects
547+ size += (size_t )(c & 0x7f ) << shift ;
546548 shift += 7 ;
547549 }
548550 obj -> size = size ;
Original file line number Diff line number Diff line change @@ -533,7 +533,8 @@ static void unpack_one(unsigned nr)
533533{
534534 unsigned shift ;
535535 unsigned char * pack ;
536- unsigned long size , c ;
536+ size_t size ;
537+ unsigned long c ;
537538 enum object_type type ;
538539
539540 obj_list [nr ].offset = consumed_bytes ;
@@ -548,7 +549,8 @@ static void unpack_one(unsigned nr)
548549 pack = fill (1 );
549550 c = * pack ;
550551 use (1 );
551- size += (c & 0x7f ) << shift ;
552+ // need shift in 64 bit space , as if shift > 32 is valid case in 4GB+ size objects
553+ size += (size_t )(c & 0x7f ) << shift ;
552554 shift += 7 ;
553555 }
554556
You can’t perform that action at this time.
0 commit comments