From 673e924c3636ca89a9458797e02ad35e9e67754e Mon Sep 17 00:00:00 2001 From: doug Date: Wed, 14 Oct 2015 08:12:12 +0000 Subject: [PATCH] Pledge "stdio" for simple games. ok semarie@ --- games/banner/banner.c | 5 ++++- games/bcd/bcd.c | 5 ++++- games/caesar/caesar.c | 5 ++++- games/factor/factor.c | 5 ++++- games/morse/morse.c | 5 ++++- games/number/number.c | 5 ++++- games/pig/pig.c | 5 ++++- games/pom/pom.c | 5 ++++- games/ppt/ppt.c | 5 ++++- games/random/random.c | 5 ++++- 10 files changed, 40 insertions(+), 10 deletions(-) diff --git a/games/banner/banner.c b/games/banner/banner.c index 7e6219a491c..7cd01e01fa9 100644 --- a/games/banner/banner.c +++ b/games/banner/banner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: banner.c,v 1.17 2015/02/10 13:50:58 tedu Exp $ */ +/* $OpenBSD: banner.c,v 1.18 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: banner.c,v 1.4 1995/04/22 11:55:15 cgd Exp $ */ /* @@ -1017,6 +1017,9 @@ main(int argc, char *argv[]) { int ch; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "w:tdh")) != -1) switch (ch) { case 'd': diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c index 0cc64d2364b..a4ea91296a6 100644 --- a/games/bcd/bcd.c +++ b/games/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcd.c,v 1.20 2014/11/07 22:17:49 schwarze Exp $ */ +/* $OpenBSD: bcd.c,v 1.21 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */ /* @@ -124,6 +124,9 @@ main(int argc, char *argv[]) int dflag = 0; int ch; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "dl")) != -1) { switch (ch) { case 'd': diff --git a/games/caesar/caesar.c b/games/caesar/caesar.c index a95999690df..22acb6c6dee 100644 --- a/games/caesar/caesar.c +++ b/games/caesar/caesar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: caesar.c,v 1.16 2014/07/03 20:30:17 schwarze Exp $ */ +/* $OpenBSD: caesar.c,v 1.17 2015/10/14 08:12:12 doug Exp $ */ /* * Copyright (c) 1989, 1993 @@ -73,6 +73,9 @@ main(int argc, char *argv[]) int obs[26], try, winner; double dot, winnerdot; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + /* check to see if we were called as rot13 */ av = argv; p = strrchr(*av, '/'); diff --git a/games/factor/factor.c b/games/factor/factor.c index 1274a0a6252..4507ce9c3e5 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: factor.c,v 1.20 2015/09/07 00:49:20 tedu Exp $ */ +/* $OpenBSD: factor.c,v 1.21 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */ /* @@ -87,6 +87,9 @@ main(int argc, char *argv[]) int ch; char *p, buf[100]; /* > max number of digits. */ + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "")) != -1) { switch (ch) { case '?': diff --git a/games/morse/morse.c b/games/morse/morse.c index ad5792e95d4..b99412cb40c 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: morse.c,v 1.15 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: morse.c,v 1.16 2015/10/14 08:12:12 doug Exp $ */ /* * Copyright (c) 1988, 1993 @@ -112,6 +112,9 @@ main(int argc, char *argv[]) int ch; char *p; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "dsh")) != -1) switch(ch) { case 'd': diff --git a/games/number/number.c b/games/number/number.c index f58bc7de701..18679182a4c 100644 --- a/games/number/number.c +++ b/games/number/number.c @@ -1,4 +1,4 @@ -/* $OpenBSD: number.c,v 1.14 2009/10/27 23:59:26 deraadt Exp $ */ +/* $OpenBSD: number.c,v 1.15 2015/10/14 08:12:12 doug Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -79,6 +79,9 @@ main(int argc, char *argv[]) int ch, first; char line[LINELEN]; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + lflag = 0; while ((ch = getopt(argc, argv, "hl")) != -1) switch (ch) { diff --git a/games/pig/pig.c b/games/pig/pig.c index 1dfd76801f2..22ac683c68b 100644 --- a/games/pig/pig.c +++ b/games/pig/pig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pig.c,v 1.11 2009/10/27 23:59:26 deraadt Exp $ */ +/* $OpenBSD: pig.c,v 1.12 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $ */ /*- @@ -49,6 +49,9 @@ main(int argc, char *argv[]) int ch; char buf[1024]; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "")) != -1) switch(ch) { case '?': diff --git a/games/pom/pom.c b/games/pom/pom.c index f36d8036fa5..f091b688042 100644 --- a/games/pom/pom.c +++ b/games/pom/pom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pom.c,v 1.16 2015/03/17 19:31:30 millert Exp $ */ +/* $OpenBSD: pom.c,v 1.17 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: pom.c,v 1.6 1996/02/06 22:47:29 jtc Exp $ */ /* @@ -85,6 +85,9 @@ main(int argc, char *argv[]) int cnt; char buf[1024]; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + if (argc > 1) { tmpt = parsetime(argv[1]); strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)", diff --git a/games/ppt/ppt.c b/games/ppt/ppt.c index 870f4568e97..a40a8c9178f 100644 --- a/games/ppt/ppt.c +++ b/games/ppt/ppt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppt.c,v 1.12 2014/11/07 22:17:49 schwarze Exp $ */ +/* $OpenBSD: ppt.c,v 1.13 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: ppt.c,v 1.4 1995/03/23 08:35:40 cgd Exp $ */ /* @@ -60,6 +60,9 @@ main(int argc, char **argv) char *p, buf[132]; int c, start, seenl, dflag, bflag; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + dflag = bflag = 0; while ((c = getopt(argc, argv, "bdh")) != -1) switch(c) { diff --git a/games/random/random.c b/games/random/random.c index 2cf7d655150..ee5ce052bbe 100644 --- a/games/random/random.c +++ b/games/random/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.12 2009/10/27 23:59:26 deraadt Exp $ */ +/* $OpenBSD: random.c,v 1.13 2015/10/14 08:12:12 doug Exp $ */ /* $NetBSD: random.c,v 1.3 1995/04/22 07:44:05 cgd Exp $ */ /* @@ -54,6 +54,9 @@ main(int argc, char *argv[]) int ch, random_exit, selected, unbuffer_output; char *ep; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + random_exit = unbuffer_output = 0; while ((ch = getopt(argc, argv, "erh")) != -1) switch (ch) { -- 2.20.1