summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2021-11-28 10:54:06 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2021-11-30 17:52:59 +0000
commit416a3fc806f47b158b489bb44f7709fc44fa4f3e (patch)
tree55f4e5f3e7c60472a2aa82e2ebdecb772e400d7c
parent6a902614350d46b759fc09a88daf9aff11f79ee8 (diff)
WriteSave: allocate enough room for full session_save_file in error
Clears warning from gcc 11.2: saveutil.c: In function ‘WriteSave’: saveutil.c:315:75: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 221 [-Wformat-truncation=] 315 | snprintf (msg, sizeof(msg), "%s: Error creating session save file %s", | ^~ 316 | Argv[0], session_save_file); | ~~~~~~~~~~~~~~~~~ saveutil.c:315:9: note: ‘snprintf’ output 36 or more bytes (assuming 1059) into a destination of size 256 315 | snprintf (msg, sizeof(msg), "%s: Error creating session save file %s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Argv[0], session_save_file); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--saveutil.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/saveutil.c b/saveutil.c
index 1b5132e..391a8b5 100644
--- a/saveutil.c
+++ b/saveutil.c
@@ -310,7 +310,7 @@ WriteSave(const char *sm_id)
if (!f)
{
- char msg[256];
+ char msg[36 + sizeof(session_save_file)];
snprintf (msg, sizeof(msg), "%s: Error creating session save file %s",
Argv[0], session_save_file);