From 1140bf01ecf4a49c32b3c385dd782cd183e730af Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Jun 2018 23:44:43 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- pack-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pack-bitmap.c') diff --git a/pack-bitmap.c b/pack-bitmap.c index 9270983e5f5..7e92d831956 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -118,7 +118,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index) { struct ewah_bitmap *b = ewah_pool_new(); - int bitmap_size = ewah_read_mmap(b, + ssize_t bitmap_size = ewah_read_mmap(b, index->map + index->map_pos, index->map_size - index->map_pos); -- cgit v1.2.3