pack-bitmap: don't perform unaligned memory access
authorJames Clarke <jrtc27@jrtc27.com>
Mon, 26 Jun 2017 15:16:12 +0000 (16:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jun 2017 19:32:31 +0000 (12:32 -0700)
The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,
so their size is not a multiple of 4. Thus the name-hash cache is only
guaranteed to be 2-byte aligned and so we must use get_be32 rather than
indexing the array directly.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap.c
index b949e517167dbac6c4c347e0a2cbdf8ca2dabbcf..09de9ba312dc0c30c4182e5e0d14a0218ffeb39a 100644 (file)
@@ -627,7 +627,7 @@ static void show_objects_for_type(
                        sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);
 
                        if (bitmap_git.hashes)
-                               hash = ntohl(bitmap_git.hashes[entry->nr]);
+                               hash = get_be32(bitmap_git.hashes + entry->nr);
 
                        show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
                }