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

@@ -2160,7 +2160,8 @@ register struct monst *mon;
if (fem) {
if (rn2(20) < ACURR(A_CHA)) {
Sprintf(qbuf, "\"That %s looks pretty. May I have it?\"",
xname(ring));
safe_qbuf("",sizeof("\"That looks pretty. May I have it?\""),
xname(ring), simple_typename(ring->otyp), "ring"));
makeknown(RIN_ADORNMENT);
if (yn(qbuf) == 'n') continue;
} else pline("%s decides she'd like your %s, and takes it.",
@@ -2181,7 +2182,9 @@ register struct monst *mon;
if (ring==uleft || ring==uright) continue;
if (rn2(20) < ACURR(A_CHA)) {
Sprintf(qbuf,"\"That %s looks pretty. Would you wear it for me?\"",
xname(ring));
safe_qbuf("",
sizeof("\"That looks pretty. Would you wear it for me?\""),
xname(ring), simple_typename(ring->otyp), "ring"));
makeknown(RIN_ADORNMENT);
if (yn(qbuf) == 'n') continue;
} else {