From 123a473e334db9f6263945d09c9089c4766587dd Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 14 Feb 2024 14:42:59 +0100 Subject: [PATCH] xwin: fix possibly missing string termination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../hw/xwin/InitOutput.c: In function ‘winFixupPaths’: 747../hw/xwin/InitOutput.c:578:9: warning: ‘strncpy’ output truncated before terminating nul copying 5 bytes from a string of the same length [-Wstringop-truncation] 748 578 | strncpy(buffer, "HOME=", 5); 749 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- hw/xwin/InitOutput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index b72cc71a5..5a42f43bb 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -577,9 +577,9 @@ winFixupPaths(void) putenv(buffer); } if (getenv("HOME") == NULL) { - char buffer[MAX_PATH + 5]; + char buffer[MAX_PATH + 5] = {0}; - strncpy(buffer, "HOME=", 5); + strncpy(buffer, "HOME=", 6); /* query appdata directory */ if (SHGetFolderPathA