Simon Josefsson wrote:
> Is the maximum string ever returned by gethostname bounded by
> MAXHOSTNAMELEN?

I expect so.

> It seems clear that FreeBSD isn't POSIX compliant here since
> HOST_NAME_MAX needs to be provided, as far as I can tell.

So, FreeBSD is POSIX compliant. See [1]: HOST_NAME_MAX is inside a section
that begins with:
  "A definition of one of the symbolic constants in the following list
   shall be omitted from <limits.h> on specific implementations where the
   corresponding value is equal to or greater than the stated minimum, but
   is unspecified.
   This indetermination might depend on the amount of available memory space
   on a specific instance of a specific implementation. The actual value
   supported by a specific instance shall be provided by the sysconf()
   function."

> I guess looking into FreeBSD libc would answer this.

[2] simply makes a system call. In the kernel, it's really an access of
an array of size MAXHOSTNAMELEN [3][4].

Bruno

[1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
[2] http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/gen/gethostname.c
[3] http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_mib.c
[4] http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/jail.h


Reply via email to