summaryrefslogtreecommitdiffstats
path: root/include/unistd.h
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2003-08-19 20:38:44 +0000
committerwollman <wollman@FreeBSD.org>2003-08-19 20:38:44 +0000
commitf2841dd3a44a167c639e1a3de8b67a9e2244d8e3 (patch)
tree39f48deff9edcea3a88c38a4cb261ee58f08cbe2 /include/unistd.h
parentb97ad4e18b7c77b56c1de1f9c206f356ae087f58 (diff)
downloadFreeBSD-src-f2841dd3a44a167c639e1a3de8b67a9e2244d8e3.zip
FreeBSD-src-f2841dd3a44a167c639e1a3de8b67a9e2244d8e3.tar.gz
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)
Diffstat (limited to 'include/unistd.h')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud