]> granicus.if.org Git - nethack/commitdiff
'O' vs perm_invent (mostly)
authorPatR <rankin@nethack.org>
Sat, 31 Aug 2019 08:38:19 +0000 (01:38 -0700)
committerPatR <rankin@nethack.org>
Sat, 31 Aug 2019 08:38:19 +0000 (01:38 -0700)
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....

doc/fixes36.3
src/options.c

index 8677345fb1f1eeb67b3cb445893c9475efe26333..2fc55c34170128f7f74547ae9084cd0753a0236b 100644 (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
 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
 toggling perm_invent (where supported) while swallowed or underwater didn't
        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
@@ -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
 EDIT_GETLIN: when naming an object or a monster use the existing name, if
        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,
        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
index 2f601df3319f9c3f167dcd6a70e12088bd55bae4..50f92ca8698326a30c08ba6573e943e28b5ff862 100644 (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) Michael Allison, 2008. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -3723,7 +3723,7 @@ boolean tinitial, tfrom_file;
             itmp = atoi(op);
         }
         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;
         } else {
             iflags.wc2_statuslines = itmp;
@@ -4052,11 +4052,11 @@ boolean tinitial, tfrom_file;
                     status_initialize(REASSESS_ONLY);
                 context.botl = TRUE;
             } 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)
                     reassign();
-                if (iflags.perm_invent)
-                    update_inventory();
+                update_inventory();
             } else if (boolopt[i].addr == &flags.lit_corridor
                        || boolopt[i].addr == &flags.dark_room) {
                 /*
@@ -4108,6 +4108,9 @@ boolean tinitial, tfrom_file;
                         set_colors();
                 }
 #endif
+            } else if (boolopt[i].addr == &iflags.use_menu_color
+                       || boolopt[i].addr == &iflags.wc2_guicolor) {
+                update_inventory();
 #endif /* TEXTCOLOR */
             }
             return retval;
@@ -4443,7 +4446,7 @@ int
 doset() /* changing options via menu by Per Liboriussen */
 {
     static boolean made_fmtstr = FALSE;
-    char buf[BUFSZ], buf2[BUFSZ] = DUMMY;
+    char buf[BUFSZ];
     const char *name;
     int i = 0, pass, boolcount, pick_cnt, pick_idx, opt_indx;
     boolean *bool_p;
@@ -4618,11 +4621,16 @@ doset() /* changing options via menu by Per Liboriussen */
 
                 if (!special_handling(compopt[opt_indx].name, setinitial,
                                       fromfile)) {
+                    char abuf[BUFSZ];
+
                     Sprintf(buf, "Set %s to what?", compopt[opt_indx].name);
-                    getlin(buf, buf2);
-                    if (buf2[0] == '\033')
+                    abuf[0] = '\0';
+                    getlin(buf, abuf);
+                    if (abuf[0] == '\033')
                         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 */
                     (void) parseoptions(buf, setinitial, fromfile);
                 }
@@ -5126,7 +5134,7 @@ boolean setinitial, setfromfile;
             iflags.menu_headings = mhattr;
     } else if (!strcmp("msgtype", optname)) {
         int opt_idx, nmt, mttyp;
-        char mtbuf[BUFSZ] = DUMMY;
+        char mtbuf[BUFSZ];
 
  msgtypes_again:
         nmt = msgtype_count();
@@ -5134,6 +5142,7 @@ boolean setinitial, setfromfile;
         if (opt_idx == 3) { /* done */
             return TRUE;
         } else if (opt_idx == 0) { /* add new */
+            mtbuf[0] = '\0';
             getlin("What new message pattern?", mtbuf);
             if (*mtbuf == '\033')
                 return TRUE;
@@ -5188,18 +5197,29 @@ boolean setinitial, setfromfile;
         }
     } else if (!strcmp("menu_colors", optname)) {
         int opt_idx, nmc, mcclr, mcattr;
-        char mcbuf[BUFSZ] = DUMMY;
+        char mcbuf[BUFSZ];
 
  menucolors_again:
         nmc = count_menucolors();
         opt_idx = handle_add_list_remove("menucolor", nmc);
         if (opt_idx == 3) { /* 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(
     "To have menu colors become active, toggle 'menucolors' option to True.");
             return TRUE;
+
         } else if (opt_idx == 0) { /* add new */
+            mcbuf[0] = '\0';
             getlin("What new menucolor pattern?", mcbuf);
             if (*mcbuf == '\033')
                 goto menucolors_done;
@@ -5212,6 +5232,7 @@ boolean setinitial, setfromfile;
                 wait_synch();
             }
             goto menucolors_again;
+
         } else { /* list (1) or remove (2) */
             int pick_idx, pick_cnt;
             int mc_idx;