summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2016-07-23 08:57:19 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2016-07-23 08:57:19 +0000
commitc6db28d8f5454012bd16f0e4b382dcf76dd822df (patch)
tree85df1b8f21c7356374baa362602d4690833a61da
parent60debcabd89d0163c61c21469b5f26de82dec3f5 (diff)
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);