@@ -629,14 +629,21 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
629629 struct packed_git * p = IN_PACK (entry );
630630 struct pack_window * w_curs = NULL ;
631631 uint32_t pos ;
632- off_t offset ;
632+ off_t offset , cur ;
633633 enum object_type type = oe_type (entry );
634+ enum object_type in_pack_type ;
634635 off_t datalen ;
635636 unsigned char header [MAX_PACK_OBJECT_HEADER ],
636637 dheader [MAX_PACK_OBJECT_HEADER ];
637638 unsigned hdrlen ;
638639 const unsigned hashsz = the_hash_algo -> rawsz ;
639- unsigned long entry_size = SIZE (entry );
640+ size_t entry_size ;
641+
642+ cur = entry -> in_pack_offset ;
643+ in_pack_type = unpack_object_header (p , & w_curs , & cur , & entry_size );
644+ if (in_pack_type < 0 )
645+ die (_ ("write_reuse_object: unable to parse object header of %s" ),
646+ oid_to_hex (& entry -> idx .oid ));
640647
641648 if (DELTA (entry ))
642649 type = (allow_ofs_delta && DELTA (entry )-> idx .offset ) ?
@@ -664,7 +671,8 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
664671 datalen -= entry -> in_pack_header_size ;
665672
666673 if (!pack_to_stdout && p -> index_version == 1 &&
667- check_pack_inflate (p , & w_curs , offset , datalen , entry_size )) {
674+ check_pack_inflate (p , & w_curs , offset , datalen ,
675+ cast_size_t_to_ulong (entry_size ))) {
668676 error (_ ("corrupt packed object for %s" ),
669677 oid_to_hex (& entry -> idx .oid ));
670678 unuse_pack (& w_curs );
@@ -1087,7 +1095,7 @@ static void write_reused_pack_one(struct packed_git *reuse_packfile,
10871095{
10881096 off_t offset , next , cur ;
10891097 enum object_type type ;
1090- unsigned long size ;
1098+ size_t size ;
10911099
10921100 offset = pack_pos_to_offset (reuse_packfile , pos );
10931101 next = pack_pos_to_offset (reuse_packfile , pos + 1 );
@@ -2243,7 +2251,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
22432251 off_t ofs ;
22442252 unsigned char * buf , c ;
22452253 enum object_type type ;
2246- unsigned long in_pack_size ;
2254+ size_t in_pack_size ;
22472255
22482256 buf = use_pack (p , & w_curs , entry -> in_pack_offset , & avail );
22492257
@@ -2270,7 +2278,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
22702278 default :
22712279 /* Not a delta hence we've already got all we need. */
22722280 oe_set_type (entry , entry -> in_pack_type );
2273- SET_SIZE (entry , in_pack_size );
2281+ SET_SIZE (entry , cast_size_t_to_ulong ( in_pack_size ) );
22742282 entry -> in_pack_header_size = used ;
22752283 if (oe_type (entry ) < OBJ_COMMIT || oe_type (entry ) > OBJ_BLOB )
22762284 goto give_up ;
@@ -2324,8 +2332,8 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
23242332 if (have_base &&
23252333 can_reuse_delta (& base_ref , entry , & base_entry )) {
23262334 oe_set_type (entry , entry -> in_pack_type );
2327- SET_SIZE (entry , in_pack_size ); /* delta size */
2328- SET_DELTA_SIZE (entry , in_pack_size );
2335+ SET_SIZE (entry , cast_size_t_to_ulong ( in_pack_size ) ); /* delta size */
2336+ SET_DELTA_SIZE (entry , cast_size_t_to_ulong ( in_pack_size ) );
23292337
23302338 if (base_entry ) {
23312339 SET_DELTA (entry , base_entry );
@@ -2734,16 +2742,18 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
27342742 struct pack_window * w_curs ;
27352743 unsigned char * buf ;
27362744 enum object_type type ;
2737- unsigned long used , avail , size ;
2745+ unsigned long used , avail ;
2746+ size_t size ;
27382747
27392748 if (e -> type_ != OBJ_OFS_DELTA && e -> type_ != OBJ_REF_DELTA ) {
2749+ unsigned long sz ;
27402750 packing_data_lock (& to_pack );
27412751 if (odb_read_object_info (the_repository -> objects ,
2742- & e -> idx .oid , & size ) < 0 )
2752+ & e -> idx .oid , & sz ) < 0 )
27432753 die (_ ("unable to get size of %s" ),
27442754 oid_to_hex (& e -> idx .oid ));
27452755 packing_data_unlock (& to_pack );
2746- return size ;
2756+ return sz ;
27472757 }
27482758
27492759 p = oe_in_pack (pack , e );
@@ -2760,7 +2770,7 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
27602770
27612771 unuse_pack (& w_curs );
27622772 packing_data_unlock (& to_pack );
2763- return size ;
2773+ return cast_size_t_to_ulong ( size ) ;
27642774}
27652775
27662776static int try_delta (struct unpacked * trg , struct unpacked * src ,
0 commit comments