From 1c232cd509c1fd9cb772bd829c3a220a5a6379bb Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 6 Oct 2009 17:14:39 +0000 Subject: [PATCH] In rtld's map_object(), use pread(..., 0) rather than read() to read the ELF header from the front of the file. As all other I/O on the binary is done using mmap(), this avoids the need for seek privileges on the file descriptor during run-time linking. MFC after: 1 month Sponsored by: Google --- libexec/rtld-elf/map_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 6de0c9e1a3d0..d231830b351d 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -273,7 +273,7 @@ get_elf_header (int fd, const char *path) } u; ssize_t nbytes; - if ((nbytes = read(fd, u.buf, PAGE_SIZE)) == -1) { + if ((nbytes = pread(fd, u.buf, PAGE_SIZE, 0)) == -1) { _rtld_error("%s: read error: %s", path, strerror(errno)); return NULL; }