summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2024-03-28 18:01:20 +0100
committerKim Woelders <kim@woelders.dk>2024-04-03 20:04:07 +0200
commit656d27ed32af4082e8062c1d7c42b65ea3a6b80f (patch)
tree3f49a79bab3059c5181eb6f8d87082dab3ff713a
parent6171150fe9f8edad3f1cfb14cec59e6a42a9c15b (diff)
TRANS(GetHostname): Fix "‘strncpy’ output truncated.." warning
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 <kim@woelders.dk> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxtrans/-/merge_requests/16>
-rw-r--r--Xtrans.c2
1 files changed, 1 insertions, 1 deletions
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';