X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/eb97288b64a4f39e9d0b328aa16a6fd4c657c0e0..b89a361943e53da59951cfbcb406221a2d5c4baa:/arithmetic/arithmetic.c diff --git a/arithmetic/arithmetic.c b/arithmetic/arithmetic.c index 29ffcb99..d06776b8 100644 --- a/arithmetic/arithmetic.c +++ b/arithmetic/arithmetic.c @@ -1,4 +1,4 @@ -/* $NetBSD: arithmetic.c,v 1.9 1997/10/15 08:53:24 is Exp $ */ +/* $NetBSD: arithmetic.c,v 1.13 1999/07/17 19:11:30 hubertf Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: arithmetic.c,v 1.9 1997/10/15 08:53:24 is Exp $"); +__RCSID("$NetBSD: arithmetic.c,v 1.13 1999/07/17 19:11:30 hubertf Exp $"); #endif #endif /* not lint */ @@ -86,19 +86,20 @@ __RCSID("$NetBSD: arithmetic.c,v 1.9 1997/10/15 08:53:24 is Exp $"); #include #include #include +#include int getrandom __P((int, int, int)); -void intr __P((int)); +void intr __P((int)) __attribute__((__noreturn__)); int main __P((int, char *[])); int opnum __P((int)); void penalise __P((int, int, int)); int problem __P((void)); void showstats __P((void)); -void usage __P((void)); +void usage __P((void)) __attribute__((__noreturn__)); -char keylist[] = "+-x/"; -char defaultkeys[] = "+-"; -char *keys = defaultkeys; +const char keylist[] = "+-x/"; +const char defaultkeys[] = "+-"; +const char *keys = defaultkeys; int nkeys = sizeof(defaultkeys) - 1; int rangemax = 10; int nright, nwrong; @@ -121,10 +122,13 @@ main(argc, argv) extern int optind; int ch, cnt; + /* Revoke setgid privileges */ + setregid(getgid(), getgid()); + while ((ch = getopt(argc, argv, "r:o:")) != -1) switch(ch) { case 'o': { - char *p; + const char *p; for (p = keys = optarg; *p; ++p) if (!strchr(keylist, *p)) @@ -161,7 +165,7 @@ main(argc, argv) /* Handle interrupt character. Print score and exit. */ void intr(dummy) - int dummy; + int dummy __attribute__((__unused__)); { showstats(); exit(0);