RFR(xs): 6991580: IPv6 Nameservers in resolv.conf throws NumberFormatException

Michael McMahon michael.x.mcmahon at oracle.com
Tue Apr 21 09:58:33 UTC 2015


On 20/04/15 18:32, Severin Gehwolf wrote:
> On Mon, 2015-04-20 at 12:24 -0400, Andrew Hughes wrote:
>> ----- Original Message -----
>>> Adding in net-dev.
>>>
>>> On Mon, 2015-04-20 at 14:02 +0200, Severin Gehwolf wrote:
>>>> Hi,
>>>>
>>>> Could I please get a review and a sponsor for the following patch?
>>>>
>>>> The issue is that JDK's internal /etc/resolv.conf nameserver parsing
>>>> does not properly account for IPv6 addresses on Linux/Unix. While the
>>>> code in com.sun.jndi.dns.DnsClient seems to support IPv6 addresses
>>>> passed in via the servers list in the constructor it expects IPv6
>>>> addresses to be wrapped in '[' and ']' respectively. However,
>>>> sun.net.dns.ResolverConfigurationImpl does no wrapping of IPv6 addresses
>>>> when parsing "nameserver" keywords from /etc/resolv.conf, thus breaking
>>>> DnsClient's contract.
>>>>
>>>> The fix is to properly wrap IPv6 literal addresses in '[' and ']' if not
>>>> already wrapped.
>>>>
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-6991580
>>>> Webrev:
>>>> http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-6991580/webrev.01/
>>>>
>>>> Testing done: Added regression test fails for unpatched 9 and passes for
>>>> patched 9.
>>>>
>>>> Thanks,
>>>> Severin
>>>>
>>>
>>>
>>>
>> It'd be better to provide public nameservers in the test comment so everyone
>> is able to run this test if they update /etc/resolv.conf appropriately.
> OK fixed:
> http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-6991580/webrev.02/
>
> FWIW, I don't think the test needs IP addresses of DNS servers to be
> functional, though. All it really does is passing it to
> InetAddress.getByName(). Prior this patch DnsClient fails to parse the
> IP literals.

That's true, but no harm having a public IP address there anyway.
I can sponsor this change for you.

- Michael


>> Google provides some: https://developers.google.com/speed/public-dns/docs/using
>>
>> $ host redhat.com 2001:4860:4860::8888
>> Using domain server:
>> Name: 2001:4860:4860::8888
>> Address: 2001:4860:4860::8888#53
>> Aliases:
>>
>> redhat.com has address 209.132.183.105
> On my F21 machine:
> $ host redhat.com 2001:4860:4860::8888
> ;; connection timed out; no servers could be reached
>
> But the test still works with a patched JDK:
> [...]
> DEBUG: 'nameserver = 127.0.0.1'
> DEBUG: 'nameserver = [2001:4860:4860::8888]'
> DEBUG: ==> Found IPv6 address in servers list: [2001:4860:4860::8888]
> DEBUG: 'nameserver = [::1]:5353'
> DEBUG: ==> Found IPv6 address in servers list: [::1]:5353
> DEBUG: 'nameserver = 127.0.0.1:5353'
> PASS: Found IPv6 address and DnsClient parsed it correctly.
>
> Contrast this to unpatched:
> [...]
> DEBUG: 'nameserver = 127.0.0.1'
> DEBUG: 'nameserver = 2001:4860:4860::8888'
> DEBUG: ==> Found IPv6 address in servers list: 2001:4860:4860::8888
> DEBUG: 'nameserver = [::1]:5353'
> DEBUG: ==> Found IPv6 address in servers list: [::1]:5353
> DEBUG: 'nameserver = 127.0.0.1:5353'
> Exception in thread "main" java.lang.RuntimeException: FAIL: Tried to parse non-[]-encapsulated IPv6 address.
> 	at IPv6NameserverPlatformParsingTest.main(IPv6NameserverPlatformParsingTest.java:59)
> Caused by: java.lang.NumberFormatException: For input string: "4860:4860::8888"
> 	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> 	at java.lang.Integer.parseInt(Integer.java:580)
> 	at java.lang.Integer.parseInt(Integer.java:615)
> 	at com.sun.jndi.dns.DnsClient.<init>(DnsClient.java:127)
> 	at IPv6NameserverPlatformParsingTest.main(IPv6NameserverPlatformParsingTest.java:57)
>
> Cheers,
> Severin
>




More information about the core-libs-dev mailing list