RFR(XS): 8202181: Correctly specify size of hostname buffer in Unix Inet*AddressImpl_getLocalHostName implementations

Thomas Stüfe thomas.stuefe at gmail.com
Fri Apr 27 05:16:49 UTC 2018


On Fri, Apr 27, 2018 at 7:02 AM, Thomas Stüfe <thomas.stuefe at gmail.com> wrote:
> Hi Christoph,
>
> code change makes sense. +1 on the "sizeof()" arg change.
>
> I would prefer it though if you would move the zero-termination out of
> the if/else altogether.

Disregard this last comment. What I meant was I would probably
unconditionally zero-terminate the result string before calling
NewStringUTF() but I guess this is not needed.

..Thomas

>
> Best Regards, Thomas
>
>
>
> On Tue, Apr 24, 2018 at 11:38 AM, Langer, Christoph
> <christoph.langer at sap.com> wrote:
>> Hi,
>>
>>
>>
>> please help reviewing a small change that I stumbled over when looking into
>> the getLocalHostName implementation. I found that the length of the hostname
>> buffer is not correctly passed to sub functions. The buffer size is
>> specified as “NI_MAXHOST + 1”, so this size should be handed down to
>> gethostname() and getnameinfo() calls, not just NI_MAXHOST. I also moved the
>> solaris #ifdefs into the else clause to spare a few lines of code.
>>
>>
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8202181
>>
>> Webrev: http://cr.openjdk.java.net/~clanger/webrevs/8202181.0/
>>
>>
>>
>> Thanks
>>
>> Christoph
>>
>>


More information about the net-dev mailing list