aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-09-01 21:45:32 +0000
committerRoland McGrath <roland@gnu.org>2001-09-01 21:45:32 +0000
commitb8f5d8dd4e542c64b385668791d52581a85aea48 (patch)
tree005cbae1c0f666933f89c1e3a64f10364cdc0715 /sysdeps
parent1bc83d2bb213bb32d8f7ae42595bbc1fec91094e (diff)
downloadglibc-b8f5d8dd4e542c64b385668791d52581a85aea48.zip
glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.tar.gz
glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.tar.bz2
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.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/gethostname.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/gethostname.c b/sysdeps/unix/sysv/gethostname.c
index ab5f602..330770c 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;
}