diff options
author | Varun Naik <vcnaik94@gmail.com> | 2019-07-13 20:01:53 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-14 15:22:29 -0700 |
commit | 02638d1e1153eb89d51a72de51ad854a88c9a178 (patch) | |
tree | a7088f78e1e48ec38c3830041fd43ba6da2040da /read-cache.c | |
parent | b697d92f56511e804b8ba20ccbe7bdc85dc66810 (diff) | |
download | git-02638d1e1153eb89d51a72de51ad854a88c9a178.tar.gz |
read-cache.c: do not die if mmap fails
do_read_index() mmaps the index, or tries to die with an error message
on failure. It should call xmmap_gently(), which returns MAP_FAILED,
rather than xmmap(), which dies with its own error message.
An easy way to cause this mmap to fail is by setting $GIT_INDEX_FILE to
a path to a directory and then invoking any command that reads from the
index.
Signed-off-by: Varun Naik <vcnaik94@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c index 22e7b9944e..4e30dafa9d 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2140,7 +2140,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz) die(_("%s: index file smaller than expected"), path); - mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0); + mmap = xmmap_gently(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0); if (mmap == MAP_FAILED) die_errno(_("%s: unable to map index file"), path); close(fd); |