@@ -1173,7 +1173,8 @@ static int store_object(
11731173 delta_count_by_type [type ]++ ;
11741174 e -> depth = last -> depth + 1 ;
11751175
1176- hdrlen = encode_in_pack_object_header (OBJ_OFS_DELTA , deltalen , hdr );
1176+ hdrlen = encode_in_pack_object_header (hdr , sizeof (hdr ),
1177+ OBJ_OFS_DELTA , deltalen );
11771178 sha1write (pack_file , hdr , hdrlen );
11781179 pack_size += hdrlen ;
11791180
@@ -1184,7 +1185,8 @@ static int store_object(
11841185 pack_size += sizeof (hdr ) - pos ;
11851186 } else {
11861187 e -> depth = 0 ;
1187- hdrlen = encode_in_pack_object_header (type , dat -> len , hdr );
1188+ hdrlen = encode_in_pack_object_header (hdr , sizeof (hdr ),
1189+ type , dat -> len );
11881190 sha1write (pack_file , hdr , hdrlen );
11891191 pack_size += hdrlen ;
11901192 }
@@ -1237,9 +1239,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
12371239 sha1file_checkpoint (pack_file , & checkpoint );
12381240 offset = checkpoint .offset ;
12391241
1240- hdrlen = snprintf ((char * )out_buf , out_sz , "blob %" PRIuMAX , len ) + 1 ;
1241- if (out_sz <= hdrlen )
1242- die ("impossibly large object header" );
1242+ hdrlen = xsnprintf ((char * )out_buf , out_sz , "blob %" PRIuMAX , len ) + 1 ;
12431243
12441244 git_SHA1_Init (& c );
12451245 git_SHA1_Update (& c , out_buf , hdrlen );
@@ -1248,9 +1248,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
12481248
12491249 git_deflate_init (& s , pack_compression_level );
12501250
1251- hdrlen = encode_in_pack_object_header (OBJ_BLOB , len , out_buf );
1252- if (out_sz <= hdrlen )
1253- die ("impossibly large object header" );
1251+ hdrlen = encode_in_pack_object_header (out_buf , out_sz , OBJ_BLOB , len );
12541252
12551253 s .next_out = out_buf + hdrlen ;
12561254 s .avail_out = out_sz - hdrlen ;
@@ -3003,7 +3001,7 @@ static void parse_get_mark(const char *p)
30033001 if (!oe )
30043002 die ("Unknown mark: %s" , command_buf .buf );
30053003
3006- snprintf (output , sizeof (output ), "%s\n" , sha1_to_hex (oe -> idx .sha1 ));
3004+ xsnprintf (output , sizeof (output ), "%s\n" , sha1_to_hex (oe -> idx .sha1 ));
30073005 cat_blob_write (output , 41 );
30083006}
30093007
0 commit comments