diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2017-10-24 10:48:26 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2017-10-24 10:48:26 +0000 |
| commit | a8b31c14d22509434fe0267b4a008546461c24a4 (patch) | |
| tree | 5c871d3cc320c278fb2411e3b349446795d0f303 /libexec | |
| parent | 5c70ebfa57f710ad9efd3bf9bd2b380ccf3d9f80 (diff) | |
Notes
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/rtld-elf/libmap.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c index e107c26e6b34..c6afd57ea3de 100644 --- a/libexec/rtld-elf/libmap.c +++ b/libexec/rtld-elf/libmap.c @@ -100,6 +100,7 @@ lmc_parse_file(char *path) { struct lmc *p; struct stat st; + ssize_t retval; int fd; char *lm_map; @@ -128,10 +129,11 @@ lmc_parse_file(char *path) } } - lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (lm_map == (const char *)MAP_FAILED) { + lm_map = xmalloc(st.st_size); + retval = read(fd, lm_map, st.st_size); + if (retval != st.st_size) { close(fd); - dbg("lm_parse_file: mmap(\"%s\") failed, %s", path, + dbg("lm_parse_file: read(\"%s\") failed, %s", path, rtld_strerror(errno)); return; } @@ -142,7 +144,7 @@ lmc_parse_file(char *path) p->ino = st.st_ino; TAILQ_INSERT_HEAD(&lmc_head, p, next); lmc_parse(lm_map, st.st_size); - munmap(lm_map, st.st_size); + free(lm_map); } static void |
