From a43819626a9f7b3aee98e3e9311b27b89c0dc5fe Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 7 Oct 2015 18:00:06 +0000 Subject: [PATCH] use tame "stdio rpath tty", for ttyname(). from Rob Pierce, who chose to do this using ktrace step by step. not the method i recommend, because it requires 100% coverage via feature tests. better to read the code and understand everything being called, then make decisions. --- usr.bin/tty/tty.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/tty/tty.c b/usr.bin/tty/tty.c index 5243afd0403..e7c451824e2 100644 --- a/usr.bin/tty/tty.c +++ b/usr.bin/tty/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.7 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: tty.c,v 1.8 2015/10/07 18:00:06 deraadt Exp $ */ /* $NetBSD: tty.c,v 1.4 1994/12/07 00:46:57 jtc Exp $ */ /* @@ -33,6 +33,7 @@ #include #include #include +#include static void usage(void); @@ -42,6 +43,9 @@ main(int argc, char *argv[]) int ch, sflag; char *t; + if (tame("stdio rpath tty", NULL) == -1) + err(1, "tame"); + sflag = 0; while ((ch = getopt(argc, argv, "s")) != -1) { switch(ch) { @@ -61,7 +65,6 @@ main(int argc, char *argv[]) exit(t ? 0 : 1); } - static void usage(void) { -- 2.20.1