'O' vs perm_invent (mostly)

Update persistent inventory window if 'implicit_uncursed', 'menucolors',
or 'guicolor' is toggled.  (curses should be changed to use menucolors
instead of guicolor to decide whether menu coloring is used.  Right now
it requires that both be On.)

Also, EDIT_GETLIN was providing junk default response when message type
or menu color looped and prompted for another entry after handling one.

Mixed in with this is a fix for easily induced buffer overflow which
has security ramifications....
This commit is contained in:
PatR
2019-08-31 01:38:19 -07:00
parent 3e0d029a45
commit d8598bd6bb
2 changed files with 43 additions and 13 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.104 $ $NHDT-Date: 1567213888 2019/08/31 01:11:28 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.105 $ $NHDT-Date: 1567240693 2019/08/31 08:38:13 $
This fixes36.3 file is here to capture information about updates in the 3.6.x This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however, lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -127,6 +127,12 @@ when a shape-shifted sandestin was turned to stone, it died and reverted to
instead of dying, make it revert to sandestin form with full health instead of dying, make it revert to sandestin form with full health
toggling perm_invent (where supported) while swallowed or underwater didn't toggling perm_invent (where supported) while swallowed or underwater didn't
necessarily update the persistent inventory window right away necessarily update the persistent inventory window right away
have 'O' update persistent inventory window if 'implicit_uncursed',
'menucolors', or 'guicolors' (curses) is toggled or if menucolors is
On and any menu color patterns are added or removed
'O's "set <option> to what?" could be used to force a buffer overflow
'O's response to bad 'statuslines' value said "must be 2 and 3" (at one point
it was "must be between 2 and 3", change it to "must be 2 or 3")
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
@@ -162,6 +168,9 @@ EDIT_GETLIN: wizard mode 'monpolycontrol' was using the getlin() answer buffer
what kind of monster?" prompt, resulting in "<x,y>" as default answer what kind of monster?" prompt, resulting in "<x,y>" as default answer
EDIT_GETLIN: when naming an object or a monster use the existing name, if EDIT_GETLIN: when naming an object or a monster use the existing name, if
there is one, as the default answer there is one, as the default answer
EDIT_GETLIN: using 'O' to set message types or menu colors was overloading the
answer buffer with other stuff, resulting in bogus default response
during repeat prompting
curses: very tall menus tried to use selector characters a-z, A-Z, and 0-9, curses: very tall menus tried to use selector characters a-z, A-Z, and 0-9,
but 0-9 should be reserved for counts and if the display was tall but 0-9 should be reserved for counts and if the display was tall
enough for more than 62 entries, arbitrary ASCII punctuation got used enough for more than 62 entries, arbitrary ASCII punctuation got used
+33 -12
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1561682566 2019/06/28 00:42:46 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.367 $ */ /* NetHack 3.6 options.c $NHDT-Date: 1567240693 2019/08/31 08:38:13 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.369 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */ /*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -3723,7 +3723,7 @@ boolean tinitial, tfrom_file;
itmp = atoi(op); itmp = atoi(op);
} }
if (itmp < 2 || itmp > 3) { if (itmp < 2 || itmp > 3) {
config_error_add("'%s' requires a value of 2 and 3", fullname); config_error_add("'%s' requires a value of 2 or 3", fullname);
retval = FALSE; retval = FALSE;
} else { } else {
iflags.wc2_statuslines = itmp; iflags.wc2_statuslines = itmp;
@@ -4052,11 +4052,11 @@ boolean tinitial, tfrom_file;
status_initialize(REASSESS_ONLY); status_initialize(REASSESS_ONLY);
context.botl = TRUE; context.botl = TRUE;
} else if (boolopt[i].addr == &flags.invlet_constant } else if (boolopt[i].addr == &flags.invlet_constant
|| boolopt[i].addr == &flags.sortpack) { || boolopt[i].addr == &flags.sortpack
|| boolopt[i].addr == &iflags.implicit_uncursed) {
if (!flags.invlet_constant) if (!flags.invlet_constant)
reassign(); reassign();
if (iflags.perm_invent) update_inventory();
update_inventory();
} else if (boolopt[i].addr == &flags.lit_corridor } else if (boolopt[i].addr == &flags.lit_corridor
|| boolopt[i].addr == &flags.dark_room) { || boolopt[i].addr == &flags.dark_room) {
/* /*
@@ -4108,6 +4108,9 @@ boolean tinitial, tfrom_file;
set_colors(); set_colors();
} }
#endif #endif
} else if (boolopt[i].addr == &iflags.use_menu_color
|| boolopt[i].addr == &iflags.wc2_guicolor) {
update_inventory();
#endif /* TEXTCOLOR */ #endif /* TEXTCOLOR */
} }
return retval; return retval;
@@ -4443,7 +4446,7 @@ int
doset() /* changing options via menu by Per Liboriussen */ doset() /* changing options via menu by Per Liboriussen */
{ {
static boolean made_fmtstr = FALSE; static boolean made_fmtstr = FALSE;
char buf[BUFSZ], buf2[BUFSZ] = DUMMY; char buf[BUFSZ];
const char *name; const char *name;
int i = 0, pass, boolcount, pick_cnt, pick_idx, opt_indx; int i = 0, pass, boolcount, pick_cnt, pick_idx, opt_indx;
boolean *bool_p; boolean *bool_p;
@@ -4618,11 +4621,16 @@ doset() /* changing options via menu by Per Liboriussen */
if (!special_handling(compopt[opt_indx].name, setinitial, if (!special_handling(compopt[opt_indx].name, setinitial,
fromfile)) { fromfile)) {
char abuf[BUFSZ];
Sprintf(buf, "Set %s to what?", compopt[opt_indx].name); Sprintf(buf, "Set %s to what?", compopt[opt_indx].name);
getlin(buf, buf2); abuf[0] = '\0';
if (buf2[0] == '\033') getlin(buf, abuf);
if (abuf[0] == '\033')
continue; continue;
Sprintf(buf, "%s:%s", compopt[opt_indx].name, buf2); Sprintf(buf, "%s:", compopt[opt_indx].name);
(void) strncat(eos(buf), abuf,
(sizeof buf - 1 - strlen(buf)));
/* pass the buck */ /* pass the buck */
(void) parseoptions(buf, setinitial, fromfile); (void) parseoptions(buf, setinitial, fromfile);
} }
@@ -5126,7 +5134,7 @@ boolean setinitial, setfromfile;
iflags.menu_headings = mhattr; iflags.menu_headings = mhattr;
} else if (!strcmp("msgtype", optname)) { } else if (!strcmp("msgtype", optname)) {
int opt_idx, nmt, mttyp; int opt_idx, nmt, mttyp;
char mtbuf[BUFSZ] = DUMMY; char mtbuf[BUFSZ];
msgtypes_again: msgtypes_again:
nmt = msgtype_count(); nmt = msgtype_count();
@@ -5134,6 +5142,7 @@ boolean setinitial, setfromfile;
if (opt_idx == 3) { /* done */ if (opt_idx == 3) { /* done */
return TRUE; return TRUE;
} else if (opt_idx == 0) { /* add new */ } else if (opt_idx == 0) { /* add new */
mtbuf[0] = '\0';
getlin("What new message pattern?", mtbuf); getlin("What new message pattern?", mtbuf);
if (*mtbuf == '\033') if (*mtbuf == '\033')
return TRUE; return TRUE;
@@ -5188,18 +5197,29 @@ boolean setinitial, setfromfile;
} }
} else if (!strcmp("menu_colors", optname)) { } else if (!strcmp("menu_colors", optname)) {
int opt_idx, nmc, mcclr, mcattr; int opt_idx, nmc, mcclr, mcattr;
char mcbuf[BUFSZ] = DUMMY; char mcbuf[BUFSZ];
menucolors_again: menucolors_again:
nmc = count_menucolors(); nmc = count_menucolors();
opt_idx = handle_add_list_remove("menucolor", nmc); opt_idx = handle_add_list_remove("menucolor", nmc);
if (opt_idx == 3) { /* done */ if (opt_idx == 3) { /* done */
menucolors_done: menucolors_done:
if (nmc > 0 && !iflags.use_menu_color) /* in case we've made a change which impacts current persistent
inventory window; we don't track whether an actual changed
occurred, so just assume there was one and that it matters;
if we're wrong, a redundant update is cheap... */
if (iflags.use_menu_color)
update_inventory();
/* menu colors aren't being used; if any are defined, remind
player how to use them */
else if (nmc > 0)
pline( pline(
"To have menu colors become active, toggle 'menucolors' option to True."); "To have menu colors become active, toggle 'menucolors' option to True.");
return TRUE; return TRUE;
} else if (opt_idx == 0) { /* add new */ } else if (opt_idx == 0) { /* add new */
mcbuf[0] = '\0';
getlin("What new menucolor pattern?", mcbuf); getlin("What new menucolor pattern?", mcbuf);
if (*mcbuf == '\033') if (*mcbuf == '\033')
goto menucolors_done; goto menucolors_done;
@@ -5212,6 +5232,7 @@ boolean setinitial, setfromfile;
wait_synch(); wait_synch();
} }
goto menucolors_again; goto menucolors_again;
} else { /* list (1) or remove (2) */ } else { /* list (1) or remove (2) */
int pick_idx, pick_cnt; int pick_idx, pick_cnt;
int mc_idx; int mc_idx;