From 656d27ed32af4082e8062c1d7c42b65ea3a6b80f Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Thu, 28 Mar 2024 18:01:20 +0100 Subject: =?UTF-8?q?TRANS(GetHostname):=20Fix=20"=E2=80=98strncpy=E2=80=99?= =?UTF-8?q?=20output=20truncated.."=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Occurs when compiling xserver master with gcc 13.2.1. In file included from /local/stuff/xorg/include/X11/Xtrans/transport.c:69: In function ‘_XSERVTransGetHostname’, inlined from ‘_XSERVTransConvertAddress’ at /local/stuff/xorg/include/X11/Xtrans/Xtransutil.c:188:12: /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:1352:5: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] 1352 | strncpy (buf, name.nodename, len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:1350:11: note: length computed here 1350 | len = strlen (name.nodename); | ^~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Kim Woelders Part-of: --- Xtrans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xtrans.c b/Xtrans.c index 3f50f6a..d826996 100644 --- a/Xtrans.c +++ b/Xtrans.c @@ -1349,7 +1349,7 @@ int TRANS(GetHostname) (char *buf, int maxlen) uname (&name); len = strlen (name.nodename); if (len >= maxlen) len = maxlen - 1; - strncpy (buf, name.nodename, len); + memcpy (buf, name.nodename, len); buf[len] = '\0'; #else buf[0] = '\0'; -- cgit v1.2.3