From 39b6f7f4628a073f0ea0cc34c12581fab7051a0a Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 29 Dec 2018 20:39:11 -0800 Subject: [PATCH] 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. --- doc/fixes36.2 | 6 +++++- src/pager.c | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 52cf55f1b..1f858d9a9 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -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 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 wizard mode ^G, creating a monster of class 'I' yielded impossible "mkclass 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 partial status lines following level changes tty: ensure that current status fields are always copied to prior status diff --git a/src/pager.c b/src/pager.c index 2ae5d8074..5b7f43c48 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -861,9 +861,9 @@ struct permonst **for_supplement; /* Check for monsters */ 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) - && def_monsyms[i].explain) { + && def_monsyms[i].explain && *def_monsyms[i].explain) { need_to_look = TRUE; if (!found) { Sprintf(out_str, "%s%s", @@ -1235,7 +1235,7 @@ coord *click_cc; } found = do_screen_description(cc, (from_screen || clicklook), sym, - out_str, &firstmatch, &supplemental_pm); + out_str, &firstmatch, &supplemental_pm); /* Finally, print out our explanation. */ if (found) { -- 2.40.0