aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-05-23 17:35:49 -0700
committerRob Landley <rob@landley.net>2017-05-24 19:56:58 -0500
commit12f0744f340746b3a1c1accfdf993d6548f33e56 (patch)
tree7fa4ac6625bcaff12c300f4ef54d53649cfe7628 /toys/posix
parent5a159cceb35fe08e444bd5a1771f8059888b03ff (diff)
downloadtoybox-12f0744f340746b3a1c1accfdf993d6548f33e56.tar.gz
Add and use xmmap.
Everyone forgets that mmap returns MAP_FAILED rather than NULL on failure. Every use of mmap in toybox was either doing the wrong check, or no check at all (including the two I personally added).
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/toys/posix/file.c b/toys/posix/file.c
index 9fa8ed0d..658708cb 100644
--- a/toys/posix/file.c
+++ b/toys/posix/file.c
@@ -109,8 +109,7 @@ static void do_elf_file(int fd, struct stat *sb)
return;
}
- map = mmap(0, sb->st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (!map) perror_exit("mmap");
+ map = xmmap(0, sb->st_size, PROT_READ, MAP_SHARED, fd, 0);
// We need to read the phdrs for dynamic vs static.
// (Note: fields got reordered for 64 bit)