svn commit: r306056 - head/usr.bin/elfdump
Ed Maste
emaste at FreeBSD.org
Tue Sep 20 21:38:13 UTC 2016
Author: emaste
Date: Tue Sep 20 21:38:12 2016
New Revision: 306056
URL: https://svnweb.freebsd.org/changeset/base/306056
Log:
elfdump: limit STDIN to no rights rather than closing it
Closing stdin/stdout/stderr is often a bad idea as a future open()
can end up with its fd. Leave it open and limit it to no rights
instead.
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D7984
Modified:
head/usr.bin/elfdump/elfdump.c
Modified: head/usr.bin/elfdump/elfdump.c
==============================================================================
--- head/usr.bin/elfdump/elfdump.c Tue Sep 20 21:33:57 2016 (r306055)
+++ head/usr.bin/elfdump/elfdump.c Tue Sep 20 21:38:12 2016 (r306056)
@@ -573,7 +573,7 @@ main(int ac, char **av)
cap_rights_init(&rights, CAP_MMAP_R);
if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS)
err(1, "unable to limit rights for %s", *av);
- close(STDIN_FILENO);
+ cap_rights_limit(STDIN_FILENO, cap_rights_init(&rights));
cap_rights_init(&rights, CAP_FSTAT, CAP_IOCTL, CAP_WRITE);
cmd = TIOCGETA; /* required by isatty(3) in printf(3) */
if ((cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) ||
More information about the svn-src-head
mailing list