]> granicus.if.org Git - nethack/commitdiff
warning fix
authornhmall <nhmall@nethack.org>
Mon, 24 Oct 2022 13:14:35 +0000 (09:14 -0400)
committernhmall <nhmall@nethack.org>
Mon, 24 Oct 2022 13:14:35 +0000 (09:14 -0400)
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,
      |             ^~~~~~~

src/mhitm.c

index 4c10f4b17ba3eec82d9fcdd0da960fed3cb1fe10..0829746f8728a3fb3b2d8538bf4bbe98a35d47e2 100644 (file)
@@ -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");