Remove all adjectives in parse(), since they are nowhere used. Fixes

crash on "carry old all" shown up by fuzz testing.  Patch from Paul
Janzen <pjanzen@foatdi.harvard.edu>.
This commit is contained in:
jsm 2000-09-22 08:19:21 +00:00
parent b283f74760
commit 0f933d0d56
6 changed files with 33 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: com2.c,v 1.13 2000/09/22 08:18:20 jsm Exp $ */
/* $NetBSD: com2.c,v 1.14 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com2.c,v 1.13 2000/09/22 08:18:20 jsm Exp $");
__RCSID("$NetBSD: com2.c,v 1.14 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -51,7 +51,7 @@ wearit()
int firstnumber, value;
firstnumber = wordnumber;
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
value = wordvalue[wordnumber];
@ -139,7 +139,7 @@ draw()
int
use()
{
while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
wordnumber++;
if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
position != FINAL) {
puts("The amulet begins to glow.");
@ -184,9 +184,7 @@ murder()
if (n == NUMOFOBJECTS) {
if (testbit(inven, LASER)) {
printf("Your laser should do the trick.\n");
n = wordnumber;
while (wordtype[++n] == ADJS)
;
n = wordnumber + 1;
switch(wordvalue[n]) {
case NORMGOD:
case TIMER:
@ -211,7 +209,7 @@ murder()
puts("You don't have suitable weapons to kill.");
} else {
printf("Your %s should do the trick.\n", objsht[n]);
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
switch (wordvalue[wordnumber]) {
case NORMGOD:

View File

@ -1,4 +1,4 @@
/* $NetBSD: com3.c,v 1.8 2000/09/10 10:51:17 jsm Exp $ */
/* $NetBSD: com3.c,v 1.9 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com3.c,v 1.8 2000/09/10 10:51:17 jsm Exp $");
__RCSID("$NetBSD: com3.c,v 1.9 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -200,7 +200,7 @@ shoot()
if (!testbit(inven, LASER))
puts("You aren't holding a blaster.");
else {
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
value = wordvalue[wordnumber];
printf("%s:\n", objsht[value]);

View File

@ -1,4 +1,4 @@
/* $NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $ */
/* $NetBSD: com4.c,v 1.11 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $");
__RCSID("$NetBSD: com4.c,v 1.11 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -57,7 +57,7 @@ take(from)
wordvalue[wordnumber] = TAKEOFF;
return (cypher());
} else {
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
value = wordvalue[wordnumber];
printf("%s:\n", objsht[value]);
@ -222,8 +222,7 @@ throw(name)
deposit = location[position].down;
break;
}
wordnumber = first;
while (wordtype[++wordnumber] == ADJS);
wordnumber = first + 1;
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
if (deposit && testbit(location[position].objects, value)) {
@ -275,7 +274,7 @@ drop(name)
int firstnumber, value;
firstnumber = wordnumber;
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
value = wordvalue[wordnumber];
printf("%s:\n", objsht[value]);
@ -337,7 +336,7 @@ eat()
int firstnumber, value;
firstnumber = wordnumber;
while (wordtype[++wordnumber] == ADJS);
wordnumber++;
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
switch (value) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: com6.c,v 1.18 2000/09/17 23:04:17 jsm Exp $ */
/* $NetBSD: com6.c,v 1.19 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com6.c,v 1.18 2000/09/17 23:04:17 jsm Exp $");
__RCSID("$NetBSD: com6.c,v 1.19 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -242,8 +242,7 @@ light()
void
dooropen()
{ /* synonyms = {open, unlock} */
while(wordtype[++wordnumber] == ADJS)
;
wordnumber++;
if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS
&& wordvalue[wordnumber] == DOOR) {
switch(position) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: cypher.c,v 1.15 2000/09/21 17:44:34 jsm Exp $ */
/* $NetBSD: cypher.c,v 1.16 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: cypher.c,v 1.15 2000/09/21 17:44:34 jsm Exp $");
__RCSID("$NetBSD: cypher.c,v 1.16 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -54,8 +54,6 @@ cypher()
char *filename, *rfilename;
size_t filename_len;
while (wordtype[wordnumber] == ADJS)
wordnumber++;
while (wordnumber <= wordcount) {
switch (wordvalue[wordnumber]) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.8 2000/09/21 17:44:34 jsm Exp $ */
/* $NetBSD: parse.c,v 1.9 2000/09/22 08:19:21 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: parse.c,v 1.8 2000/09/21 17:44:34 jsm Exp $");
__RCSID("$NetBSD: parse.c,v 1.9 2000/09/22 08:19:21 jsm Exp $");
#endif
#endif /* not lint */
@ -110,6 +110,17 @@ parse()
wordtype[n] = wp->article;
}
}
/* We never use adjectives for anything, so yank them all. */
for (n = 1; n < wordcount; n++)
if (wordtype[n] == ADJS) {
int i;
for (i = n + 1; i < wordcount; i++) {
wordtype[i - 1] = wordtype[i];
wordvalue[i - 1] = wordvalue[i];
strcpy(words[i - 1], words[i]);
}
wordcount--;
}
/* Don't let a comma mean AND if followed by a verb. */
for (n = 0; n < wordcount; n++)
if (wordvalue[n] == AND && words[n][0] == ','