From e7af4a5084846dd9ec2ddab7b22c46b38b83c862 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Jan 2023 04:24:18 -0800 Subject: [PATCH] Resize menudemo_t filepath to fix -Wformat-truncation --- src/g_demo.h | 2 +- src/k_menufunc.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/g_demo.h b/src/g_demo.h index 333d7620b..981396b89 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -82,7 +82,7 @@ typedef enum { } menudemotype_e; struct menudemo_t { - char filepath[256]; + char filepath[1023 + 256]; // see M_PrepReplayList and sizeof menupath menudemotype_e type; char title[65]; // Null-terminated for string prints diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 191542ca7..52390f4a4 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -6621,7 +6621,9 @@ void M_PrepReplayList(void) else { extrasmenu.demolist[i].type = MD_NOTLOADED; - snprintf(extrasmenu.demolist[i].filepath, 255, "%s%s", menupath, dirmenu[i] + DIR_STRING); + snprintf(extrasmenu.demolist[i].filepath, sizeof extrasmenu.demolist[i].filepath, + // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). + "%s%.255s", menupath, dirmenu[i] + DIR_STRING); sprintf(extrasmenu.demolist[i].title, "....."); } }