diff options
author | Kim Woelders <kim@woelders.dk> | 2024-03-28 18:01:20 +0100 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2024-04-03 20:04:07 +0200 |
commit | 656d27ed32af4082e8062c1d7c42b65ea3a6b80f (patch) | |
tree | 3f49a79bab3059c5181eb6f8d87082dab3ff713a /Xtrans.c | |
parent | 6171150fe9f8edad3f1cfb14cec59e6a42a9c15b (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>
Diffstat (limited to 'Xtrans.c')
-rw-r--r-- | Xtrans.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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'; |