bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HOST_NAME_MAX


From: Bruno Haible
Subject: Re: HOST_NAME_MAX
Date: Mon, 10 Aug 2009 20:12:33 +0200
User-agent: KMail/1.9.9

Simon Josefsson wrote:
> Then I'm less sure that it makes sense for
> gnulib's limit.h to define HOST_NAME_MAX -- programs written against
> POSIX should not assume that symbol exists.

On the other hand, the support of POSIX for unspecified maximum host
name lengths is weak: You see in [1] that
  - when the host name is longer than namelen, the string is truncated,
    possibly NUL terminated or not,
  - when gethostname fails, it is unspecified whether it sets errno.
The reality (see lib/xgethostname.c) is even worse:
  - when the host name is longer than namelen, then some platforms
    return -1, others don't; some platforms even write past the specified
    namelength bytes,
  - the errnos appearing in this case are far from standard.

I think it's a favour that gnulib can do to its users, to not force
developers to deal with these pitfalls.

And don't tell me that host names longer than 256 bytes occur frequently :-)

> Do sysconf work under mingw?  Gnulib could provide a replacement if not.

That would be some work, because of the many arguments that sysconf
should support. [2]

Bruno

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
[2] http://www.opengroup.org/onlinepubs/9699919799/functions/sysconf.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]