diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-07 07:12:54 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-07 07:12:54 +0000 |
commit | 92eb952610a47e72b227f82fa5b443acef185daa (patch) | |
tree | cb87ad6c6e14eb1fade24bd87b9eba352868bc5e /lib | |
parent | 8a836816791cedf4b8b9c0387db0bbbffa977a86 (diff) |
per XPG, gethostname() with a short buffer returns truncated data - not ENOMEM.
As permitted, make the truncated buffer be NUL terminated.
make getdomainname() match.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/getdomainname.3 | 12 | ||||
-rw-r--r-- | lib/libc/gen/gethostname.3 | 19 |
2 files changed, 23 insertions, 8 deletions
diff --git a/lib/libc/gen/getdomainname.3 b/lib/libc/gen/getdomainname.3 index 42c620c1ed1..fe4d944c3a7 100644 --- a/lib/libc/gen/getdomainname.3 +++ b/lib/libc/gen/getdomainname.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getdomainname.3,v 1.5 1998/05/13 08:50:54 deraadt Exp $ +.\" $OpenBSD: getdomainname.3,v 1.6 1998/07/07 07:12:52 deraadt Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -53,8 +53,8 @@ The parameter .Fa namelen specifies the size of the .Fa name -array. The returned name is null-terminated unless insufficient -space is provided. +array. If insufficient space is provided, the returned name is truncated. +The returned name is always null-terminated. .Pp .Fn Setdomainname sets the domain name of the host machine to be @@ -92,7 +92,11 @@ Domain names are limited to .Dv MAXHOSTNAMELEN (from .Ao Pa sys/param.h Ac ) -characters, currently 256. +characters, currently 256. This includes the terminating NUL character. +.Pp +If the buffer passed to +.Fn getdomainname +is too small, other operating systems may not gaurantee termination with NUL. .Sh HISTORY The .Nm diff --git a/lib/libc/gen/gethostname.3 b/lib/libc/gen/gethostname.3 index 881ba586e92..32b46fb9e1e 100644 --- a/lib/libc/gen/gethostname.3 +++ b/lib/libc/gen/gethostname.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: gethostname.3,v 1.5 1998/05/13 08:50:56 deraadt Exp $ +.\" $OpenBSD: gethostname.3,v 1.6 1998/07/07 07:12:53 deraadt Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -53,8 +53,8 @@ The parameter .Fa namelen specifies the size of the .Fa name -array. The returned name is null-terminated unless insufficient -space is provided. +array. If insufficient space is provided, the returned name is truncated. +The returned name is always null-terminated. .Pp .Fn Sethostname sets the name of the host machine to be @@ -90,9 +90,20 @@ Host names are limited to .Dv MAXHOSTNAMELEN (from .Ao Pa sys/param.h Ac ) -characters, currently 256. +characters, currently 256. This includes the terminating NUL character. +.Pp +If the buffer passed to +.Fn getdomainname +is smaller than +.Dv MAXHOSTNAMELEN , +other operating systems may not gaurantee termination with NUL. .Sh HISTORY The .Nm function call appeared in .Bx 4.2 . +.Sh STANDARDS +The +.Nm +function call conforms to +.St -xpg4.2 . |