From: bluhm Date: Sat, 23 Jul 2016 08:57:18 +0000 (+0000) Subject: Before terminal characteristics are displayed, stty(1) activates X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f752bed1e5713441e97471570b631bbe2609ec4e;p=openbsd 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@ --- 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);