From 63d44e1faa04cea5ccac3d79af166dcd61120959 Mon Sep 17 00:00:00 2001 From: rwatson Date: Tue, 6 Oct 2009 17:14:39 +0000 Subject: 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(-) (limited to 'libexec') diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 6de0c9e..d231830 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; } -- cgit v1.1