Subject: Re: gethostname and getdomainname
To: Ignatios Souvatzis <firstname.lastname@example.org>
From: Christos Zoulas <email@example.com>
Date: 11/14/1999 08:42:16
On Nov 14, 8:23am, firstname.lastname@example.org (Ignatios Souvatzis) wrote:
-- Subject: Re: gethostname and getdomainname
| Uhm... checking the return code won't help for portable programs....
| neither SUSV2 nor Solaris document that an error return happens if the
| name is truncated, and the errno value for this condition.
| (We dont do it, either).
| So our gethostname() would need to _silently_ non-Null-terminate?
| Observed behaviour:
| OS man:terminate man:errno does:terminate err/errno
| SUSV2 maybe - n/a n/a
| Solaris no - yes 0/no
| SunOS no - yes 0/no
| Ultrix no - yes 0/no
| DU4.0 maybe - yes 0/no
| Parix no man page ? no 1/0
| (in man:terminate, I counted as "no" occurences of "null-terminated unless the
| provided buffer is not sufficient". I counted as "maybe": "if enough space
| is provided, the name is null-terminated".)
| (Parix is breandead in that it returns 1 even when it didn't truncate
| the name.)
Solaris claims that the return buffer is not null terminated, but then
goes ahead and null terminates it :-)
Ok. I suppose then that it is better to null terminate the buffer in
gethostname() and return an error. I still think though that it is better
to make sysctl return a non-null-terminated string.