diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-05 13:30:31 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-05 13:30:31 +0000 |
commit | 79a5b1930464b264a4172ae6a34b14370a4c238f (patch) | |
tree | 238d4929c561d9347a472863bafcdfd4bfae64e4 | |
parent | da8b794f1a034a35fd3254d7ba14f02e02ffbe5f (diff) |
tame "stdio rpath" or tame "stdio" suffices for all of these programs.
fairly easy to audit by running nm and noticing nothing beyond base
stdio except for fopen/freopen. Then review all callpaths to those
functions, and place the tame() calls.
ok sthen
-rw-r--r-- | usr.bin/cal/cal.c | 5 | ||||
-rw-r--r-- | usr.bin/colrm/colrm.c | 5 | ||||
-rw-r--r-- | usr.bin/column/column.c | 26 | ||||
-rw-r--r-- | usr.bin/comm/comm.c | 5 | ||||
-rw-r--r-- | usr.bin/diff3/diff3prog.c | 5 | ||||
-rw-r--r-- | usr.bin/dirname/dirname.c | 5 |
6 files changed, 37 insertions, 14 deletions
diff --git a/usr.bin/cal/cal.c b/usr.bin/cal/cal.c index 144b8635d21..017f0addf5e 100644 --- a/usr.bin/cal/cal.c +++ b/usr.bin/cal/cal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cal.c,v 1.28 2015/03/17 19:31:30 millert Exp $ */ +/* $OpenBSD: cal.c,v 1.29 2015/10/05 13:30:30 deraadt Exp $ */ /* $NetBSD: cal.c,v 1.6 1995/03/26 03:10:24 glass Exp $ */ /* @@ -150,6 +150,9 @@ main(int argc, char *argv[]) int ch, month, year, yflag; const char *errstr; + if (tame("stdio", NULL) == -1) + err(1, "tame"); + yflag = year = 0; while ((ch = getopt(argc, argv, "jmwy")) != -1) switch(ch) { diff --git a/usr.bin/colrm/colrm.c b/usr.bin/colrm/colrm.c index 2c5e4d86462..26e601cd1c8 100644 --- a/usr.bin/colrm/colrm.c +++ b/usr.bin/colrm/colrm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: colrm.c,v 1.9 2009/10/27 23:59:36 deraadt Exp $ */ +/* $OpenBSD: colrm.c,v 1.10 2015/10/05 13:30:30 deraadt Exp $ */ /* $NetBSD: colrm.c,v 1.4 1995/09/02 05:51:37 jtc Exp $ */ /*- @@ -52,6 +52,9 @@ main(int argc, char *argv[]) int ch; char *p; + if (tame("stdio", NULL) == -1) + err(1, "tame"); + while ((ch = getopt(argc, argv, "")) != -1) switch(ch) { case '?': diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index f1dbed0db5d..f37aeca06bd 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -1,4 +1,4 @@ -/* $OpenBSD: column.c,v 1.19 2014/05/22 19:50:34 millert Exp $ */ +/* $OpenBSD: column.c,v 1.20 2015/10/05 13:30:30 deraadt Exp $ */ /* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */ /* @@ -76,6 +76,9 @@ main(int argc, char *argv[]) } else termwidth = win.ws_col; + if (tame("stdio rpath", NULL) == -1) + err(1, "tame"); + tflag = xflag = 0; while ((ch = getopt(argc, argv, "c:s:tx")) != -1) switch(ch) { @@ -100,16 +103,21 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!*argv) + if (!*argv) { input(stdin); - else for (; *argv; ++argv) - if ((fp = fopen(*argv, "r"))) { - input(fp); - (void)fclose(fp); - } else { - warn("%s", *argv); - eval = 1; + } else { + for (; *argv; ++argv) { + if ((fp = fopen(*argv, "r"))) { + input(fp); + (void)fclose(fp); + } else { + warn("%s", *argv); + eval = 1; + } } + } + if (tame("stdio", NULL) == -1) + err(1, "tame"); if (!entries) exit(eval); diff --git a/usr.bin/comm/comm.c b/usr.bin/comm/comm.c index 56271f464fc..d15b931e545 100644 --- a/usr.bin/comm/comm.c +++ b/usr.bin/comm/comm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comm.c,v 1.8 2009/10/27 23:59:37 deraadt Exp $ */ +/* $OpenBSD: comm.c,v 1.9 2015/10/05 13:30:30 deraadt Exp $ */ /* $NetBSD: comm.c,v 1.10 1995/09/05 19:57:43 jtc Exp $ */ /* @@ -61,6 +61,9 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); + if (tame("stdio rpath", NULL) == -1) + err(1, "tame"); + flag1 = flag2 = flag3 = 1; compare = strcoll; while ((ch = getopt(argc, argv, "123f")) != -1) diff --git a/usr.bin/diff3/diff3prog.c b/usr.bin/diff3/diff3prog.c index 86d836e59d5..921da78a548 100644 --- a/usr.bin/diff3/diff3prog.c +++ b/usr.bin/diff3/diff3prog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3prog.c,v 1.15 2015/09/05 09:47:08 jsg Exp $ */ +/* $OpenBSD: diff3prog.c,v 1.16 2015/10/05 13:30:30 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -145,6 +145,9 @@ main(int argc, char **argv) { int ch, i, m, n; + if (tame("stdio rpath", NULL) == -1) + err(1, "tame"); + eflag = 0; oflag = 0; while ((ch = getopt(argc, argv, "EeXx3")) != -1) { diff --git a/usr.bin/dirname/dirname.c b/usr.bin/dirname/dirname.c index 03f457ca626..1d4d8c547a0 100644 --- a/usr.bin/dirname/dirname.c +++ b/usr.bin/dirname/dirname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirname.c,v 1.13 2010/08/10 22:05:36 sobrado Exp $ */ +/* $OpenBSD: dirname.c,v 1.14 2015/10/05 13:30:30 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -33,6 +33,9 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); + if (tame("stdio", NULL) == -1) + err(1, "tame"); + while ((ch = getopt(argc, argv, "")) != -1) { switch (ch) { default: |