diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2006-03-27 00:10:16 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2006-03-27 00:10:16 +0000 |
commit | 1e83c82a3bf562241906e89f69222dfa40422206 (patch) | |
tree | 3cb64e8eb5d6a8755f5b2b2f0f18285a9094a131 /games/adventure | |
parent | 8865bd2a63b0dd63bb6398ca8fef60e3f5669d34 (diff) |
assorted fixes mostly from coverity via netbsd via jasper adriaanse via tech
Diffstat (limited to 'games/adventure')
-rw-r--r-- | games/adventure/init.c | 6 | ||||
-rw-r--r-- | games/adventure/io.c | 13 | ||||
-rw-r--r-- | games/adventure/vocab.c | 6 |
3 files changed, 14 insertions, 11 deletions
diff --git a/games/adventure/init.c b/games/adventure/init.c index cd249bc050a..1dd1bd81053 100644 --- a/games/adventure/init.c +++ b/games/adventure/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.10 2006/03/27 00:10:14 tedu Exp $ */ /* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */ /*- @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.9 2004/07/09 15:59:26 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.10 2006/03/27 00:10:14 tedu Exp $"; #endif #endif /* not lint */ @@ -89,7 +89,7 @@ linkdata(void) /* secondary data manipulation */ int i, j; /* array linkages */ - for (i = 1; i <= LOCSIZ; i++) + for (i = 1; i < LOCSIZ; i++) if (ltext[i].seekadr != 0 && travel[i] != 0) if ((travel[i]->tverb) == 1) cond[i] = 2; diff --git a/games/adventure/io.c b/games/adventure/io.c index d2a03f58e88..7bdd2914757 100644 --- a/games/adventure/io.c +++ b/games/adventure/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.15 2004/07/09 15:59:26 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.16 2006/03/27 00:10:14 tedu Exp $ */ /* $NetBSD: io.c,v 1.3 1995/04/24 12:21:37 cgd Exp $ */ /*- @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: io.c,v 1.15 2004/07/09 15:59:26 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.16 2006/03/27 00:10:14 tedu Exp $"; #endif #endif /* not lint */ @@ -378,7 +378,7 @@ rtrav(void) /* read travel table */ if (locc == -1) return; if (locc != oldloc) { /* getting a new entry */ - t = travel[locc] = (struct travlist *) malloc(sizeof (struct travlist)); + t = travel[locc] = calloc(1, sizeof(*t)); if (t == NULL) err(1, NULL); /* printf("New travel list for %d\n", locc); */ @@ -400,10 +400,13 @@ rtrav(void) /* read travel table */ m = atoi(buf); } while (breakch != LF) { /* only do one line at a time */ + if (t == NULL) + errx(1, "corrupt file"); if (entries++) { - t = t->next = (struct travlist *) malloc(sizeof (struct travlist)); - if (t == NULL) + t->next = calloc(1, sizeof (*t->next)); + if (t->next == NULL) err(1, NULL); + t = t->next; } t->tverb = rnum();/* get verb from the file */ t->tloc = n; /* table entry mod 1000 */ diff --git a/games/adventure/vocab.c b/games/adventure/vocab.c index 688a1f5b1c8..5b3ed32fbc6 100644 --- a/games/adventure/vocab.c +++ b/games/adventure/vocab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vocab.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $ */ +/* $OpenBSD: vocab.c,v 1.12 2006/03/27 00:10:14 tedu Exp $ */ /* $NetBSD: vocab.c,v 1.2 1995/03/21 12:05:13 cgd Exp $ */ /*- @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: vocab.c,v 1.11 2004/07/09 15:59:26 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: vocab.c,v 1.12 2006/03/27 00:10:14 tedu Exp $"; #endif #endif /* not lint */ @@ -189,7 +189,7 @@ vocab(const char *word, int type, int value) } exitloop2: /* hashed entry does not match */ - if (adr + 1 == hash || (adr == HTSIZE && hash == 0)) + if (adr + 1 == hash || hash == 0) errx(1, "Hash table overflow"); } } |