diff --git a/doc/fixes34.2 b/doc/fixes34.2 index 996900f07..4a58fce8b 100644 --- a/doc/fixes34.2 +++ b/doc/fixes34.2 @@ -50,6 +50,7 @@ give more explicit feedback for exploding bag of holding help display for "list of game options" misformats runmode and scroll_amount pit created by land mine explosion doesn't start out concealed update map display sooner when pushed boulder triggers land mine explosion +prevent fatal error from prompt string overflow in lift_object() Platform- and/or Interface-Specific Fixes diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 3994c9062..f508fce4f 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -26,6 +26,7 @@ dust vortex-induced blindness should kick in immediately when blindfold is removed or glop is wiped off prayer/unicorn-horn won't fix blindness while still engulfed in a dust vortex since it will just return immediately +prevent fatal error from prompt string overflow in lift_object() Platform- and/or Interface-Specific Fixes diff --git a/src/pickup.c b/src/pickup.c index 90262c3f5..ba54adc2a 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1122,12 +1122,18 @@ boolean telekinesis; } else { char qbuf[BUFSZ]; long savequan = obj->quan; + unsigned textleft; obj->quan = *cnt_p; - Sprintf(qbuf, "%s %s. Continue?", + Strcpy(qbuf, (next_encumbr > HVY_ENCUMBER) ? overloadmsg : (next_encumbr > MOD_ENCUMBER) ? nearloadmsg : - moderateloadmsg, doname(obj)); + moderateloadmsg); + textleft = QBUFSZ - (strlen(qbuf) + sizeof(" . Continue?")); + Sprintf(eos(qbuf), " %s. Continue?", + (strlen(doname(obj)) < textleft) ? doname(obj) : + (strlen(simple_typename(obj->otyp)) < textleft) ? + an(simple_typename(obj->otyp)) : something); obj->quan = savequan; switch (ynq(qbuf)) { case 'q': result = -1; break;