aboutsummaryrefslogtreecommitdiffstats
path: root/packfile.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-11-13 00:07:01 -0500
committerJunio C Hamano <gitster@pobox.com>2020-11-16 13:41:35 -0800
commita9bc372ef8210e60d924ec6c0b46624c6d0a4033 (patch)
tree0bf3ffe7c78e4f19e508785e98254b6a3c9049d9 /packfile.c
parentf86f769550ef7fb5162a9cd4be5e2be7981d063b (diff)
downloadgit-a9bc372ef8210e60d924ec6c0b46624c6d0a4033.tar.gz
use size_t to store pack .idx byte offsets
We sometimes store the offset into a pack .idx file as an "unsigned long", but the mmap'd size of a pack .idx file can exceed 4GB. This is sufficient on LP64 systems like Linux, but will be too small on LLP64 systems like Windows, where "unsigned long" is still only 32 bits. Let's use size_t, which is a better type for an offset into a memory buffer. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/packfile.c b/packfile.c
index a72c2a261f..63fe9ee8be 100644
--- a/packfile.c
+++ b/packfile.c
@@ -164,8 +164,8 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
* variable sized table containing 8-byte entries
* for offsets larger than 2^31.
*/
- unsigned long min_size = 8 + 4*256 + (size_t)nr*(hashsz + 4 + 4) + hashsz + hashsz;
- unsigned long max_size = min_size;
+ size_t min_size = 8 + 4*256 + (size_t)nr*(hashsz + 4 + 4) + hashsz + hashsz;
+ size_t max_size = min_size;
if (nr)
max_size += ((size_t)nr - 1)*8;
if (idx_size < min_size || idx_size > max_size)