freebsd-dev/lib/libc
Garrett Wollman effcb5eca3 Change gethostname() to set errno to ENAMETOOLONG instead of ENOMEM
when the buffer is not long enough to hold the current host name.
POSIX does not standardize error returns for gethostname(), so it
doesn't matter which one we use, but ENAMETOOLONG is at least a little
more intuitive, and mi suggests the existence of prior art.  I've been
running with this change for a while on my home machine with no
effect.  At the same time, I've updated the prototype for
gethostname() to use the correct standard type (size_t) for the
namelen argument.

All of the in-tree callers fall into one of the following categories:
1) Call perror() or equivalent when gethostname() fails.
2) Ignore gethostname()'s return value entirely, potentially resulting
in data corruption if the buffer is too small.
3) Fall back to a (possibly sensible) default value if gethostname()
fails.

Many of the callers I examined shows signs of confusion about the
correct sizing of the host name buffer.  gethostname(3) now has more
information about this, as well as updated standards information.

PR:		48114
Submitted by:	mi (in part)
2003-08-19 20:38:44 +00:00
..
alpha Fix wrong identifier on .end directive. The SYSCALL macro does name 2003-08-16 18:59:08 +00:00
amd64 Add the mlockall() and munlockall() system calls. 2003-08-11 07:14:08 +00:00
compat-43 Explain the relationship to POSIX. 2003-06-20 22:41:00 +00:00
db Fix a sizeof error in __bt_put: when writing they key and data sizes 2003-05-30 11:05:08 +00:00
gdtoa Userland spinlocks bad. Sleep locks good. 2003-06-21 08:20:14 +00:00
gen Change gethostname() to set errno to ENAMETOOLONG instead of ENOMEM 2003-08-19 20:38:44 +00:00
gmon Use C99 compatible ASM statements. 2003-06-02 02:32:22 +00:00
i386 Add the mlockall() and munlockall() system calls. 2003-08-11 07:14:08 +00:00
ia64 Add the mlockall() and munlockall() system calls. 2003-08-11 07:14:08 +00:00
include Back out the `hiding' of strlcpy and strlcat. Several people 2003-05-01 19:03:14 +00:00
locale Fix the case of the encoding name in the ENCODING line. Names are 2003-08-10 11:41:38 +00:00
net An u_int8_t can never be bigger than 255, so remove a useless check. 2003-07-25 12:23:25 +00:00
nls Back out the `hiding' of strlcpy and strlcat. Several people 2003-05-01 19:03:14 +00:00
posix1e Print group name in getfacl output when calculating an effective 2003-07-24 23:33:25 +00:00
powerpc Add the mlockall() and munlockall() system calls. 2003-08-11 07:14:08 +00:00
quad libc_r wasn't so tied to libc for 22 months. 2002-11-18 09:50:57 +00:00
regex Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go). 2003-02-16 17:29:11 +00:00
rpc Kill prototype for __msgwrite too. It is not needed anymore. 2003-06-15 10:55:39 +00:00
sparc64 Add the mlockall() and munlockall() system calls. 2003-08-11 07:14:08 +00:00
stdio Add more useful cross-references to the SEE ALSO section. 2003-07-05 07:55:34 +00:00
stdlib Replace some syscalls with libc version, this makes abort work better with 2003-08-16 11:43:57 +00:00
stdtime Fixes to locale code to properly use indirect pointers in order to prevent 2003-06-13 00:14:07 +00:00
string * Merge index(3) and rindex(3) to index(3) since the two functions are 2003-07-28 22:50:42 +00:00
sys Make the documentation of PT_STEP match its implementation: the 2003-08-11 13:13:46 +00:00
uuid Remove stale DCE 1.1 pointers to the IBM site. The URLs aren't valid 2003-08-08 19:18:43 +00:00
xdr Fix amd(8) clients, if a FreeBSD mountd(8) server is used. 2003-05-28 09:13:09 +00:00
yp Back out the `hiding' of strlcpy and strlcat. Several people 2003-05-01 19:03:14 +00:00
Makefile style.Makefile(5) 2003-08-18 15:25:39 +00:00