multi-pack-index: fix 32-bit vs 64-bit size check
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 13 Sep 2018 18:02:23 +0000 (11:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Sep 2018 20:49:41 +0000 (13:49 -0700)
When loading a 64-bit offset, we intend to check that off_t can store
the resulting offset. However, the condition accidentally checks the
32-bit offset to see if it is smaller than a 64-bit value. Fix it,
and this will be covered by a test in the 'git multi-pack-index verify'
command in a later commit.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
diff --git a/midx.c b/midx.c
index c13c6f9d72e34e75434db69fcf6a22dc19c613e5..db9c49bb2bbfeede06e4402c8f84b792b1641dbc 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -236,7 +236,7 @@ static off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos)
        offset32 = get_be32(offset_data + sizeof(uint32_t));
 
        if (m->chunk_large_offsets && offset32 & MIDX_LARGE_OFFSET_NEEDED) {
        offset32 = get_be32(offset_data + sizeof(uint32_t));
 
        if (m->chunk_large_offsets && offset32 & MIDX_LARGE_OFFSET_NEEDED) {
-               if (sizeof(offset32) < sizeof(uint64_t))
+               if (sizeof(off_t) < sizeof(uint64_t))
                        die(_("multi-pack-index stores a 64-bit offset, but off_t is too small"));
 
                offset32 ^= MIDX_LARGE_OFFSET_NEEDED;
                        die(_("multi-pack-index stores a 64-bit offset, but off_t is too small"));
 
                offset32 ^= MIDX_LARGE_OFFSET_NEEDED;