Subject: gethostname and getdomainname
To: None <email@example.com>
From: Ignatios Souvatzis <firstname.lastname@example.org>
Date: 11/13/1999 10:56:48
our gethostname and getdomainname do not conform to their own manual pages.
If insufficient space is provided, the truncated name is not returned.
There is an open PR (kern/7836) about this.
I investigated, and found that our sysctl system call does not conform to
its specification if strings are to be returned.
That is, instead of passing back the truncated string and setting ENOMEM,
it does not return anything (only reports the error).
Christos' suggestion is to fix this.
With this change and a small amount of code (to restore errno) I can fix
gethostname & friends.
Theres an open issue (to me).
Our manual page promises that a truncated name will not be null-terminated.
SUSV2 specifies that a truncated name may or may not be null-terminated.
I would like to make sysctl null-terminating, for the sake of robustness
(The error is reported anyway, and this way, the returned truncated string
is ready-to-use if the caller decides to do so).
Now, our manual page forbids this (for get(host|domain)name). Is this mandated
by XPG4.2, or just the behaviour of our former implementation (the current
does't return anything)?