diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-05 06:26:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-05 06:26:34 +0000 |
commit | a7c42a994d59cafe37c0c355d9b55aa2d2e355f0 (patch) | |
tree | d535f6a20207fd1401e837d55f5fc00f87441bcf | |
parent | 379c061a64a6060c4e04f90439922e037af03e13 (diff) |
tame "stdio rpath" early on, but if we discover only stdin is being
operated on switch to tame "stdio". Reformat a very ugly code block
without braces to squeeze the tame calls in.
ok doug
-rw-r--r-- | usr.bin/fold/fold.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/usr.bin/fold/fold.c b/usr.bin/fold/fold.c index 194f0c33427..521971de6c6 100644 --- a/usr.bin/fold/fold.c +++ b/usr.bin/fold/fold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fold.c,v 1.15 2015/02/06 09:10:55 tedu Exp $ */ +/* $OpenBSD: fold.c,v 1.16 2015/10/05 06:26:33 deraadt Exp $ */ /* $NetBSD: fold.c,v 1.6 1995/09/01 01:42:44 jtc Exp $ */ /*- @@ -56,6 +56,9 @@ main(int argc, char *argv[]) unsigned int width; const char *errstr; + if (tame("stdio rpath", NULL) == -1) + err(1, "tame"); + width = 0; lastch = '\0'; prevoptind = 1; @@ -99,14 +102,19 @@ main(int argc, char *argv[]) if (width == 0) width = DEFLINEWIDTH; - if (!*argv) + if (!*argv) { + if (tame("stdio", NULL) == -1) + err(1, "tame"); fold(width); - else for (; *argv; ++argv) - if (!freopen(*argv, "r", stdin)) { - err(1, "%s", *argv); - /* NOTREACHED */ - } else - fold(width); + } else { + for (; *argv; ++argv) { + if (!freopen(*argv, "r", stdin)) + err(1, "%s", *argv); + /* NOTREACHED */ + else + fold(width); + } + } exit(0); } |