overflow if 'word' arg points to full QBUFSZ buf

This prevents a buffer overflow that was encountered during fuzzing,
but the underlying issue in the caller dodip() is still pending.

That appears to be the result of 'obuf' not being filled with
appropriate content prior to being used at line 2343 in potion.c.
This commit is contained in:
nhmall
2024-09-14 12:54:34 -04:00
parent 351a8fa99c
commit 60dc14952d

View File

@@ -1930,7 +1930,8 @@ getobj(
menuquery[0] = qbuf[0] = '\0';
if (iflags.force_invmenu)
Sprintf(menuquery, "What do you want to %s?", word);
Snprintf(menuquery, sizeof menuquery,
"What do you want to %s?", word);
if (!allowed_choices || *allowed_choices == HANDS_SYM
|| *buf == HANDS_SYM)
handsbuf = getobj_hands_txt(word, qbuf);