]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-bitmap: make bitmap header handling hash agnostic
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 19 Feb 2019 00:04:54 +0000 (00:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 02:57:37 +0000 (11:57 +0900)
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>
pack-bitmap-write.c
pack-bitmap.c
pack-bitmap.h

index 5566e94abed9f0838d4c1d999ee8e90159000256..c82fb01fd758ae328b1b9eb05623b7263a43d5fe 100644 (file)
@@ -535,7 +535,7 @@ void bitmap_writer_finish(struct pack_idx_entry **index,
        header.entry_count = htonl(writer.selected_nr);
        hashcpy(header.checksum, writer.pack_checksum);
 
-       hashwrite(f, &header, sizeof(header));
+       hashwrite(f, &header, sizeof(header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz);
        dump_bitmap(f, writer.commits);
        dump_bitmap(f, writer.trees);
        dump_bitmap(f, writer.blobs);
index 4695aaf6b4eda41ec2479a326ddbe7a0bed065ab..b53f37243c363d42778dea561d91db9cdf1e35bf 100644 (file)
@@ -163,7 +163,7 @@ static int load_bitmap_header(struct bitmap_index *index)
        }
 
        index->entry_count = ntohl(header->entry_count);
-       index->map_pos += sizeof(*header);
+       index->map_pos += sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz;
        return 0;
 }
 
index 8418ba8c7929ed49aec17d5a25d8d0a309f971b8..344ba23af9b3b61ac01f211f707bb6cfe4223a4e 100644 (file)
@@ -14,7 +14,7 @@ struct bitmap_disk_header {
        uint16_t version;
        uint16_t options;
        uint32_t entry_count;
-       unsigned char checksum[20];
+       unsigned char checksum[GIT_MAX_RAWSZ];
 };
 
 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};