resolve a warning in sounds.c
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);
| ^~~~~~~
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user