summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2016-07-23 08:57:18 +0000
committerbluhm <bluhm@openbsd.org>2016-07-23 08:57:18 +0000
commitf752bed1e5713441e97471570b631bbe2609ec4e (patch)
tree2768b682c914b5291d52d89d0d5bb68761b9ea43
parentFix a few CPUID emulation issues: (diff)
downloadwireguard-openbsd-f752bed1e5713441e97471570b631bbe2609ec4e.tar.xz
wireguard-openbsd-f752bed1e5713441e97471570b631bbe2609ec4e.zip
Before terminal characteristics are displayed, stty(1) activates
pledge(2). Then the values cannot be modified anymore. Let stty error out if the display and modify mode are combined on the command line to avoid a pledge violation later on. OK deraadt@
-rw-r--r--bin/stty/stty.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/stty/stty.c b/bin/stty/stty.c
index 7de9b8f28e6..4d70ae6687a 100644
--- a/bin/stty/stty.c
+++ b/bin/stty/stty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stty.c,v 1.19 2016/03/23 14:52:42 mmcc Exp $ */
+/* $OpenBSD: stty.c,v 1.20 2016/07/23 08:57:18 bluhm Exp $ */
/* $NetBSD: stty.c,v 1.11 1995/03/21 09:11:30 cgd Exp $ */
/*-
@@ -97,11 +97,15 @@ args: argc -= optind;
/* FALLTHROUGH */
case BSD:
case POSIX:
+ if (*argv)
+ errx(1, "either display or modify");
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
print(&i.t, &i.win, i.ldisc, fmt);
break;
case GFLAG:
+ if (*argv)
+ errx(1, "either display or modify");
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
gprint(&i.t, &i.win, i.ldisc);