final qbuf patch

This is my final src mod to ensure that a qbuf does not overflow due to
a lengthy named object.  These recent patches, coupled with the core yn_function() patch earlier, should make it much rarer for a QBUFSZ
buffer overflow to occur in a window port routine (unless the window
port routine has its own bugs, but that isn't the core's fault).
This commit is contained in:
nethack.allison
2003-05-10 21:11:16 +00:00
parent 0f7508090d
commit 6f56da5261
3 changed files with 16 additions and 7 deletions

View File

@@ -307,7 +307,9 @@ pick_lock(pick) /* pick a lock with a given object */
else if (picktyp != LOCK_PICK) verb = "unlock", it = 1;
else verb = "pick";
Sprintf(qbuf, "There is %s here, %s %s?",
doname(otmp), verb, it ? "it" : "its lock");
safe_qbuf("", sizeof("There is here, unlock its lock?"),
doname(otmp), an(simple_typename(otmp->otyp)), "a box"),
verb, it ? "it" : "its lock");
c = ynq(qbuf);
if(c == 'q') return(0);
@@ -469,7 +471,10 @@ doforce() /* try to force a chest with your weapon */
doname(otmp), otmp->obroken ? "broken" : "unlocked");
continue;
}
Sprintf(qbuf,"There is %s here, force its lock?", doname(otmp));
Sprintf(qbuf,"There is %s here, force its lock?",
safe_qbuf("", sizeof("There is here, force its lock?"),
doname(otmp), an(simple_typename(otmp->otyp)),
"a box"));
c = ynq(qbuf);
if(c == 'q') return(0);