diff options
author | Roland McGrath <roland@gnu.org> | 2001-09-01 21:45:32 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-09-01 21:45:32 +0000 |
commit | b8f5d8dd4e542c64b385668791d52581a85aea48 (patch) | |
tree | 005cbae1c0f666933f89c1e3a64f10364cdc0715 /sysdeps/unix | |
parent | 1bc83d2bb213bb32d8f7ae42595bbc1fec91094e (diff) | |
download | glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.tar glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.tar.gz glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.tar.bz2 glibc-b8f5d8dd4e542c64b385668791d52581a85aea48.zip |
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/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; } |