alphabet sour warning

A recently added impossible to check for an(Null) and an("") was
triggered by the fuzzer:  Alphabet soup: 'an("")'.  I reproduced it a
couple of times and tracked it do_screen_description(for '/' command)
matching the symbol from mapglyph to monster class #0, a placeholder
with symbol value '\0'.  So mapglyph() returned a symbol of '\0', but
not necessary from showsyms[0 + SYM_OFF_M].

The pager lookup code's monster loop shouldn't have been attempting
to match against class #0, and since this fix I haven't been able to
reproduce the situation again.  But I also didn't trigger it with a
bunch of temporary checks in mapglyph() so don't know what is really
going on under the hood.
This commit is contained in:
PatR
2018-12-29 20:39:11 -08:00
parent d418008b31
commit 39b6f7f462
2 changed files with 9 additions and 5 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.217 $ $NHDT-Date: 1546129154 2018/12/30 00:19:14 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.218 $ $NHDT-Date: 1546144745 2018/12/30 04:39:05 $
This fixes36.2 file is here to capture information about updates in the 3.6.x This fixes36.2 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.1 in April 2018. Please note, however, lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -357,6 +357,10 @@ when built with STATUS_HILITES enabled (the default), gold on status line
was missing '$' prefix for symset:Blank was missing '$' prefix for symset:Blank
wizard mode ^G, creating a monster of class 'I' yielded impossible "mkclass wizard mode ^G, creating a monster of class 'I' yielded impossible "mkclass
found no class 35 monsters" found no class 35 monsters"
in some unknown circumstance, examining something on the map could match bogus
monster class #0 and trigger impossible "Alphabet soup: 'an("")'."
(fix avoids the warning but underlying cause is a mystery; noticed
with the fuzzer, which swaps symbol sets in and out at random)
tty: turn off an optimization that is the suspected cause of Windows reported tty: turn off an optimization that is the suspected cause of Windows reported
partial status lines following level changes partial status lines following level changes
tty: ensure that current status fields are always copied to prior status tty: ensure that current status fields are always copied to prior status
+4 -4
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pager.c $NHDT-Date: 1545774524 2018/12/25 21:48:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.145 $ */ /* NetHack 3.6 pager.c $NHDT-Date: 1546144745 2018/12/30 04:39:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.146 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -861,9 +861,9 @@ struct permonst **for_supplement;
/* Check for monsters */ /* Check for monsters */
if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
for (i = 0; i < MAXMCLASSES; i++) { for (i = 1; i < MAXMCLASSES; i++) {
if (sym == (looked ? showsyms[i + SYM_OFF_M] : def_monsyms[i].sym) if (sym == (looked ? showsyms[i + SYM_OFF_M] : def_monsyms[i].sym)
&& def_monsyms[i].explain) { && def_monsyms[i].explain && *def_monsyms[i].explain) {
need_to_look = TRUE; need_to_look = TRUE;
if (!found) { if (!found) {
Sprintf(out_str, "%s%s", Sprintf(out_str, "%s%s",
@@ -1235,7 +1235,7 @@ coord *click_cc;
} }
found = do_screen_description(cc, (from_screen || clicklook), sym, found = do_screen_description(cc, (from_screen || clicklook), sym,
out_str, &firstmatch, &supplemental_pm); out_str, &firstmatch, &supplemental_pm);
/* Finally, print out our explanation. */ /* Finally, print out our explanation. */
if (found) { if (found) {