From: nhmall Date: Mon, 24 Oct 2022 13:14:35 +0000 (-0400) Subject: warning fix X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2bd3b6b556ab20189b3051828daee262cad1e85;p=nethack warning fix mhitm.c: In function 'hitmm': mhitm.c:583:30: warning: '%s' directive writing between 8 and 9 bytes into a region of size between 0 and 255 [-Wformat-overflow=] 583 | Sprintf(buf, "%s %s", magr_name, | ^~ In file included from ../include/config.h:671, from ../include/hack.h:10, from mhitm.c:6: ../include/global.h:279:24: note: 'sprintf' output between 10 and 266 bytes into a destination of size 256 279 | #define Sprintf (void) sprintf mhitm.c:583:13: note: in expansion of macro 'Sprintf' 583 | Sprintf(buf, "%s %s", magr_name, | ^~~~~~~ --- diff --git a/src/mhitm.c b/src/mhitm.c index 4c10f4b17..0829746f8 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -580,7 +580,7 @@ hitmm( Strcpy(magr_name, Monnam(magr)); if (compat) { - Sprintf(buf, "%s %s", magr_name, + Snprintf(buf, sizeof buf, "%s %s", magr_name, mdef->mcansee ? "smiles at" : "talks to"); pline("%s %s %s.", buf, mon_nam(mdef), (compat == 2) ? "engagingly" : "seductively");