From 13394d12e5f1b913908267ae4247429d6be3af72 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 1 Feb 2021 20:02:12 -0500 Subject: [PATCH] resolve a warning in sounds.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sounds.c: In function ‘add_sound_mapping’: sounds.c:1381:33: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=] 1381 | Sprintf(filespec, "%s/%s", sounddir, filename); | ^ In file included from ../include/config.h:631, from ../include/hack.h:10, from sounds.c:5: ../include/global.h:274:24: note: ‘sprintf’ output 2 or more bytes (assuming 257) into a destination of size 256 274 | #define Sprintf (void) sprintf sounds.c:1381:9: note: in expansion of macro ‘Sprintf’ 1381 | Sprintf(filespec, "%s/%s", sounddir, filename); | ^~~~~~~ --- src/sounds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sounds.c b/src/sounds.c index d6df797bb..a43ecb402 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1378,7 +1378,7 @@ add_sound_mapping(const char* mapping) raw_print("sound file name too long"); return 0; } - Sprintf(filespec, "%s/%s", sounddir, filename); + Snprintf(filespec, sizeof filespec, "%s/%s", sounddir, filename); if (idx >= 0 || can_read_file(filespec)) { new_map = (audio_mapping *) alloc(sizeof *new_map);