Skip to content

Commit c7bcded

Browse files
hubertfhubertf
authored andcommitted
The patch below does some minor cleanup of adventure(6): an additional
use of const I missed in bin/6041; avoiding a signed/unsigned warning; marking an unused parameter as such; revoking setgid privileges (including the saved gid) rather than setuid ones; includes and function prototypes in setup.c; the string passed to err() should not end with a `.'. Together with the patch sent concerning adventure's EOF handling, this synchronises adventure(6) in NetBSD with the Linux port of the NetBSD games. Via PR 6557 by Joseph Myers <jsm28@cam.ac.uk>
1 parent 08ab0f3 commit c7bcded

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

games/adventure/crc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: crc.c,v 1.6 1998/09/13 00:07:24 hubertf Exp $ */
1+
/* $NetBSD: crc.c,v 1.7 1999/02/10 00:29:21 hubertf Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -42,13 +42,13 @@
4242
static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93";
4343
static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91";
4444
#else
45-
__RCSID("$NetBSD: crc.c,v 1.6 1998/09/13 00:07:24 hubertf Exp $");
45+
__RCSID("$NetBSD: crc.c,v 1.7 1999/02/10 00:29:21 hubertf Exp $");
4646
#endif
4747
#endif /* not lint */
4848

4949
#include "extern.h"
5050

51-
unsigned long crctab[] = {
51+
const unsigned long crctab[] = {
5252
0x7fffffff,
5353
0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
5454
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
@@ -111,7 +111,7 @@ unsigned long crctab[] = {
111111
*/
112112

113113
unsigned long crcval;
114-
int step;
114+
unsigned int step;
115115

116116
void
117117
crc_start()

games/adventure/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $ */
1+
/* $NetBSD: main.c,v 1.13 1999/02/10 00:29:21 hubertf Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993
@@ -48,7 +48,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
4848
#if 0
4949
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
5050
#else
51-
__RCSID("$NetBSD: main.c,v 1.12 1998/09/14 09:29:08 hubertf Exp $");
51+
__RCSID("$NetBSD: main.c,v 1.13 1999/02/10 00:29:21 hubertf Exp $");
5252
#endif
5353
#endif /* not lint */
5454

@@ -73,9 +73,8 @@ main(argc, argv)
7373
int rval, ll;
7474
struct text *kk;
7575

76-
/* adventure doesn't need setuid-ness, so, just get rid of it */
77-
if (setuid(getuid()) < 0)
78-
warn("setuid");
76+
/* revoke setgid privileges from dm */
77+
setregid(getgid(), getgid());
7978

8079
init(); /* Initialize everything */
8180
signal(SIGINT, trapdel);

games/adventure/setup.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $ */
1+
/* $NetBSD: setup.c,v 1.6 1999/02/10 00:29:21 hubertf Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
4646
#if 0
4747
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
4848
#else
49-
__RCSID("$NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $");
49+
__RCSID("$NetBSD: setup.c,v 1.6 1999/02/10 00:29:21 hubertf Exp $");
5050
#endif
5151
#endif /* not lint */
5252

@@ -64,6 +64,8 @@ __RCSID("$NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $");
6464
#define SIG2 " * Sterday, 6 Thrimidge S.R. 1993, 15:24"
6565

6666
#include <stdio.h>
67+
#include <stdlib.h>
68+
#include <err.h>
6769
#include "hdr.h" /* SEED lives in there; keep them coordinated. */
6870

6971
#define USAGE "Usage: setup file > data.c (file is typically glorkz)"
@@ -73,6 +75,8 @@ __RCSID("$NetBSD: setup.c,v 1.5 1998/09/13 15:23:40 hubertf Exp $");
7375

7476
#define LINE 10 /* How many values do we get on a line? */
7577

78+
int main __P((int, char *[]));
79+
7680
int
7781
main(argc, argv)
7882
int argc;
@@ -85,7 +89,7 @@ main(argc, argv)
8589
errx(1, USAGE);
8690

8791
if ((infile = fopen(argv[1], "r")) == NULL)
88-
err(1, "Can't read file %s.", argv[1]);
92+
err(1, "Can't read file %s", argv[1]);
8993
puts("/*\n * data.c: created by setup from the ascii data file.");
9094
puts(SIG1);
9195
puts(SIG2);

0 commit comments

Comments
 (0)