pack-bitmap: make bitmap header handling hash agnostic

Increase the checksum field in struct bitmap_disk_header to be GIT_MAX_RAWSZ bytes in length and ensure that we hash the proper number of bytes out when computing the bitmap checksum. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 19, 2019 at 00:04 UTC 0f4d6cada83dc6bd6b6b24dc0d2b3e6460c645cb
3 files changed +3 -3
pack-bitmap-write.c
+1 -1
@@ -535,7 +535,7 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
535 header.entry_count = htonl(writer.selected_nr);
536 hashcpy(header.checksum, writer.pack_checksum);
537
538 - hashwrite(f, &header, sizeof(header));
538 + hashwrite(f, &header, sizeof(header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz);
539 dump_bitmap(f, writer.commits);
540 dump_bitmap(f, writer.trees);
541 dump_bitmap(f, writer.blobs);
pack-bitmap.c
+1 -1
@@ -163,7 +163,7 @@ static int load_bitmap_header(struct bitmap_index *index)
163 }
164
165 index->entry_count = ntohl(header->entry_count);
166 - index->map_pos += sizeof(*header);
166 + index->map_pos += sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz;
167 return 0;
168 }
169
pack-bitmap.h
+1 -1
@@ -14,7 +14,7 @@ struct bitmap_disk_header {
14 uint16_t version;
15 uint16_t options;
16 uint32_t entry_count;
17 - unsigned char checksum[20];
17 + unsigned char checksum[GIT_MAX_RAWSZ];
18 };
19
20 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};