diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-01-17 19:08:23 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-01-19 19:04:56 (GMT) |
commit | ad622a256f0dd0be44ca17f58b3f5b43cedb4320 (patch) | |
tree | aa26cd44a6bada37277730382febb9505b167731 /packfile.c | |
parent | 2512f15446149235156528dafbe75930c712b29e (diff) | |
download | git-ad622a256f0dd0be44ca17f58b3f5b43cedb4320.zip git-ad622a256f0dd0be44ca17f58b3f5b43cedb4320.tar.gz git-ad622a256f0dd0be44ca17f58b3f5b43cedb4320.tar.bz2 |
packfile: use get_be64() for large offsets
The pack-index version 2 format uses two 4-byte integers in
network-byte order to represent one 8-byte value. The current
implementation has several code clones for stitching these integers
together.
Use get_be64() to create an 8-byte integer from two 4-byte integers
represented this way.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r-- | packfile.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -1702,8 +1702,7 @@ off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n) return off; index += p->num_objects * 4 + (off & 0x7fffffff) * 8; check_pack_index_ptr(p, index); - return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) | - ntohl(*((uint32_t *)(index + 4))); + return get_be64(index); } } |