From efed3bc136ab175fcf7cfe61fd0b35383cfd0dcc Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 3 Oct 2015 02:18:21 +0000 Subject: uniq has a complicated initialization around getopt. beforehands, we can tame "stdio rpath wpath cpath"; all three paths abilities are needed for it to setup the right files (worst case spotted by sthen). later once the files are opened, the program is only looking at strings and outputing via stdio functions, so we can tame "stdio". --- usr.bin/uniq/uniq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'usr.bin/uniq/uniq.c') diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 7645f85062f..69dcf28c7ac 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uniq.c,v 1.19 2013/11/26 19:25:39 deraadt Exp $ */ +/* $OpenBSD: uniq.c,v 1.20 2015/10/03 02:18:20 deraadt Exp $ */ /* $NetBSD: uniq.c,v 1.7 1995/08/31 22:03:48 jtc Exp $ */ /* @@ -61,6 +61,9 @@ main(int argc, char *argv[]) int ch; char *prevline, *thisline; + if (tame("stdio rpath wpath cpath", NULL) == -1) + err(1, "tame"); + obsolete(argv); while ((ch = getopt(argc, argv, "cdf:s:u")) != -1) { const char *errstr; @@ -119,6 +122,9 @@ main(int argc, char *argv[]) usage(); } + if (tame("stdio", NULL) != 0) + err(1, "tame"); + prevline = malloc(MAXLINELEN); thisline = malloc(MAXLINELEN); if (prevline == NULL || thisline == NULL) -- cgit v1.2.3