svn commit: r197808 - head/libexec/rtld-elf

Robert Watson rwatson at FreeBSD.org
Tue Oct 6 17:14:39 UTC 2009


Author: rwatson
Date: Tue Oct  6 17:14:39 2009
New Revision: 197808
URL: http://svn.freebsd.org/changeset/base/197808

Log:
  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

Modified:
  head/libexec/rtld-elf/map_object.c

Modified: head/libexec/rtld-elf/map_object.c
==============================================================================
--- head/libexec/rtld-elf/map_object.c	Tue Oct  6 17:10:38 2009	(r197807)
+++ head/libexec/rtld-elf/map_object.c	Tue Oct  6 17:14:39 2009	(r197808)
@@ -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;
     }


More information about the svn-src-head mailing list