ewah: adjust callers of ewah_read_mmap()
The return value of ewah_read_mmap() is now an ssize_t, since we could (in theory) process up to 32GB of data. This would never happen in practice, but a corrupt or malicious .bitmap or index file could convince us to do so. Let's make sure that we don't stuff the value into an int, which would cause us to incorrectly move our pointer forward. We'd always move too little, since negative values are used for reporting errors. So the worst case is just that we end up reporting a corrupt file, not an out-of-bounds read. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 14, 2018 at 23:44 UTC
1140bf01ecf4a49c32b3c385dd782cd183e730af
2 files changed
+3
-2
dir.c
+2
-1
@@ -2831,7 +2831,8 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
2831
struct read_data rd;
2832
const unsigned char *next = data, *end = (const unsigned char *)data + sz;
2833
const char *ident;
2834
- int ident_len, len;
2834
+ int ident_len;
2835
+ ssize_t len;
2836
const char *exclude_per_dir;
2837
2838
if (sz <= 1 || end[-1] != '\0')
pack-bitmap.c
+1
-1
@@ -118,7 +118,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index)
118
{
119
struct ewah_bitmap *b = ewah_pool_new();
120
121
- int bitmap_size = ewah_read_mmap(b,
121
+ ssize_t bitmap_size = ewah_read_mmap(b,
122
index->map + index->map_pos,
123
index->map_size - index->map_pos);
124