diff --git a/src/potion.c b/src/potion.c index 25e5e4f0c..68c9d165e 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 potion.c $NHDT-Date: 1716668700 2024/05/25 20:25:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.265 $ */ +/* NetHack 3.7 potion.c $NHDT-Date: 1726356849 2024/09/14 23:34:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.270 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2261,29 +2261,28 @@ dodip(void) shortestname = (is_hands || is_plural(obj) || pair_of(obj)) ? "them" : "it"; drink_ok_extra = 0; + /* + * Bypass safe_qbuf() since it doesn't handle varying suffix without + * an awful lot of support work. Format the object once, even though + * the fountain and pool prompts offer a lot more room for it. + * 3.6.0 used thesimpleoname() unconditionally, which posed no risk + * of buffer overflow but drew bug reports because it omits user- + * supplied type name. + * getobj: "What do you want to dip into? [xyz or ?*] " + */ + if (is_hands) { + Snprintf(obuf, sizeof obuf, "your %s", makeplural(body_part(HAND))); + } else { + Strcpy(obuf, short_oname(obj, doname, thesimpleoname, + /* 128 - (24 + 54 + 1) leaves 49 for + */ + QBUFSZ - sizeof "What do you want to dip\ + into? [abdeghjkmnpqstvwyzBCEFHIKLNOQRTUWXZ#-# or ?*] ")); + } + /* preceding #dip with 'm' skips the possibility of dipping into pools, fountains, and sinks plus the extra prompting which those entail */ if (!iflags.menu_requested) { - /* - * Bypass safe_qbuf() since it doesn't handle varying suffix without - * an awful lot of support work. Format the object once, even though - * the fountain and pool prompts offer a lot more room for it. - * 3.6.0 used thesimpleoname() unconditionally, which posed no risk - * of buffer overflow but drew bug reports because it omits user- - * supplied type name. - * getobj: "What do you want to dip into? [xyz or ?*] " - */ - if (is_hands) { - Snprintf(obuf, sizeof(obuf), "your %s", - makeplural(body_part(HAND))); - } else { - Strcpy(obuf, short_oname(obj, doname, thesimpleoname, - /* 128 - (24 + 54 + 1) leaves 49 for - */ - QBUFSZ - sizeof "What do you want to dip\ - into? [abdeghjkmnpqstvwyzBCEFHIKLNOQRTUWXZ#-# or ?*] ")); - } - /* Is there a fountain to dip into here? */ if (!can_reach_floor(FALSE)) { ; /* can't dip something into fountain or pool if can't reach */