Skip to content

Commit

Permalink
MFC r355676:
Browse files Browse the repository at this point in the history
rtld: make checks for mmap(2) failures compliant with documentation.
  • Loading branch information
kostikbel committed Dec 20, 2019
1 parent ca046cb commit 643e7b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libexec/rtld-elf/map_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ map_object(int fd, const char *path, const struct stat *sb)
base_flags |= MAP_FIXED | MAP_EXCL;

mapbase = mmap(base_addr, mapsize, PROT_NONE, base_flags, -1, 0);
if (mapbase == (caddr_t) -1) {
if (mapbase == MAP_FAILED) {
_rtld_error("%s: mmap of entire address space failed: %s",
path, rtld_strerror(errno));
goto error;
Expand Down Expand Up @@ -259,7 +259,7 @@ map_object(int fd, const char *path, const struct stat *sb)
bss_addr = mapbase + (bss_vaddr - base_vaddr);
if (bss_vlimit > bss_vaddr) { /* There is something to do */
if (mmap(bss_addr, bss_vlimit - bss_vaddr, data_prot,
data_flags | MAP_ANON, -1, 0) == (caddr_t)-1) {
data_flags | MAP_ANON, -1, 0) == MAP_FAILED) {
_rtld_error("%s: mmap of bss failed: %s", path,
rtld_strerror(errno));
goto error1;
Expand Down Expand Up @@ -343,7 +343,7 @@ get_elf_header(int fd, const char *path, const struct stat *sbp)

hdr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_PREFAULT_READ,
fd, 0);
if (hdr == (Elf_Ehdr *)MAP_FAILED) {
if (hdr == MAP_FAILED) {
_rtld_error("%s: read error: %s", path, rtld_strerror(errno));
return (NULL);
}
Expand Down

0 comments on commit 643e7b0

Please sign in to comment.