Date: Tue, 20 Sep 2016 21:38:12 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306056 - head/usr.bin/elfdump Message-ID: <201609202138.u8KLcCqf007578@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) ||
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609202138.u8KLcCqf007578>