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:
Roland McGrath 2001-09-01 21:45:32 +00:00
parent 1bc83d2bb2
commit b8f5d8dd4e

View File

@ -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;
}