Code Review 7024560: InetAddress.getLocalHost().getHostName() returns localhost for hostnames of length HOST_NAME_MAX
michael.x.mcmahon at oracle.com
Wed Mar 9 08:20:54 PST 2011
Chris Hegarty wrote:
> Alan, Michael,
> In Java_java_net_Inet(4|6)AddressImpl_getLocalHostName
> JVM_GetHostName, a.k.a gethostname, is returning ENAMETOOLONG. Then
> falling back to use "localhost", the assumption was that failure would
> only happen when something went wrong, maybe networking is not setup.
> It appears that on many Linux variations the given buffer length
> should include space for the null terminator. Our given buffers
> already account for this, just need to pass down the correct length to
Looks fine. I guess a regression test isn't practical in this case.
More information about the net-dev