corpse_xname() fix

Potential write out of bounds, in front of the block of obufs.
Not exploitable but could conceivably trigger a crash.
This commit is contained in:
PatR
2020-03-04 01:58:22 -08:00
parent cb18f60331
commit 12c2f84f64
2 changed files with 7 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 objnam.c $NHDT-Date: 1580070220 2020/01/26 20:23:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.291 $ */
/* NetHack 3.7 objnam.c $NHDT-Date: 1583315888 2020/03/04 09:58:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.293 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1374,7 +1374,8 @@ struct obj *otmp;
const char *adjective;
unsigned cxn_flags; /* bitmask of CXN_xxx values */
{
char *nambuf = nextobuf();
/* some callers [aobjnam()] rely on prefix area that xname() sets aside */
char *nambuf = nextobuf() + PREFIX;
int omndx = otmp->corpsenm;
boolean ignore_quan = (cxn_flags & CXN_SINGULAR) != 0,
/* suppress "the" from "the unique monster corpse" */
@@ -1525,8 +1526,7 @@ struct obj *obj;
/* format the object */
if (obj->otyp == CORPSE) {
buf = nextobuf();
Strcpy(buf, corpse_xname(obj, (const char *) 0, CXN_NORMAL));
buf = corpse_xname(obj, (const char *) 0, CXN_NORMAL);
} else if (obj->otyp == SLIME_MOLD) {
/* concession to "most unique deaths competition" in the annual
devnull tournament, suppress player supplied fruit names because