Skip to content

Commit 1140bf0

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d2e330 commit 1140bf0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,8 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
28312831
struct read_data rd;
28322832
const unsigned char *next = data, *end = (const unsigned char *)data + sz;
28332833
const char *ident;
2834-
int ident_len, len;
2834+
int ident_len;
2835+
ssize_t len;
28352836
const char *exclude_per_dir;
28362837

28372838
if (sz <= 1 || end[-1] != '\0')

pack-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index)
118118
{
119119
struct ewah_bitmap *b = ewah_pool_new();
120120

121-
int bitmap_size = ewah_read_mmap(b,
121+
ssize_t bitmap_size = ewah_read_mmap(b,
122122
index->map + index->map_pos,
123123
index->map_size - index->map_pos);
124124

0 commit comments

Comments
 (0)