summaryrefslogtreecommitdiff
path: root/usr.bin/getopt/getopt.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-07 06:39:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-07 06:39:17 +0000
commit52a91d8ef64919f17946ea8e13bb920df4be2057 (patch)
treea92d74065d96a7a802e936c9d25288e5f0c86efe /usr.bin/getopt/getopt.c
parentca7ac784427790a3ea92b654e159d4a92c7779cc (diff)
tame "stdio". It would take some doing for this to contain a bug, but
just in case -- now it can barely do anything when it goes wrong.
Diffstat (limited to 'usr.bin/getopt/getopt.c')
-rw-r--r--usr.bin/getopt/getopt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/getopt/getopt.c b/usr.bin/getopt/getopt.c
index f0c3869181f..b0781e62058 100644
--- a/usr.bin/getopt/getopt.c
+++ b/usr.bin/getopt/getopt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getopt.c,v 1.8 2009/10/27 23:59:38 deraadt Exp $ */
+/* $OpenBSD: getopt.c,v 1.9 2015/10/07 06:39:16 deraadt Exp $ */
/*
* This material, written by Henry Spencer, was released by him
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <err.h>
int
main(int argc, char *argv[])
@@ -17,6 +18,9 @@ main(int argc, char *argv[])
int c;
int status = 0;
+ if (tame("stdio", NULL) == -1)
+ err(1, "tame");
+
optind = 2; /* Past the program name and the option letters. */
while ((c = getopt(argc, argv, argv[1])) != -1)
switch (c) {