mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 07:10:06 +00:00
2001-08-27 Roland McGrath <roland@frob.com>
* sysdeps/unix/sysv/gethostname.c (__gethostname): When LEN is too short, copy that much into NAME anyway before returning error.
This commit is contained in:
parent
1bc83d2bb2
commit
b8f5d8dd4e
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user