diff options
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/gethostname.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/gethostname.c b/sysdeps/unix/sysv/gethostname.c index ab5f6021c7..330770c8b3 100644 --- a/sysdeps/unix/sysv/gethostname.c +++ b/sysdeps/unix/sysv/gethostname.c @@ -36,13 +36,13 @@ __gethostname (name, len) return -1; node_len = strlen (buf.nodename) + 1; + memcpy (name, buf.nodename, len < node_len ? len : node_len); + if (node_len > len) { __set_errno (ENAMETOOLONG); return -1; } - - memcpy (name, buf.nodename, node_len); return 0; } |