Code Review 7024560: InetAddress.getLocalHost().getHostName() returns localhost for hostnames of length HOST_NAME_MAX
Alan Bateman
Alan.Bateman at oracle.com
Thu Mar 10 04:15:55 PST 2011
Chris Hegarty wrote:
>
>
> On 03/ 9/11 05:07 PM, Alan Bateman wrote:
>> Chris Hegarty wrote:
>>> :
>>> I tested on a few different Linux machines and instrumented the error
>>> handling code, it is definitely failing with ENAMETOOLONG.
>> Okay, must be a glibc thing. The changes you have look okay to me but
>> would be nice to ensure that the hostname is null-terminated (for
>> platforms that don't fail with ENAMETOOLONG).
>
> Yes, Solaris is also not clear on null termination either. Best to
> ensure the hostname is null-terminated.
>
> http://cr.openjdk.java.net/~chegar/7024560/webrev.01/webrev/
The updated changes look good to me.
-Alan.
More information about the net-dev
mailing list