Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be unavailable on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1203666 - /etc/resolv.conf nameserver with ipv6 address causes jndi NumberFormatException
Summary: /etc/resolv.conf nameserver with ipv6 address causes jndi NumberFormatException
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: java-1.7.0-openjdk
Version: 7.1
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Andrew John Hughes
QA Contact: Lukáš Zachar
URL: https://bugs.openjdk.java.net/browse/...
Depends On: 1210739
TreeView+ depends on / blocked
Reported: 2015-03-19 11:47 UTC by Alon Bar-Lev
Modified: 2016-01-04 05:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2015-11-19 03:55:07 UTC
Target Upstream Version:

Attachments (Terms of Use)
Resolve.java (591 bytes, text/plain)
2015-03-19 11:47 UTC, Alon Bar-Lev
no flags Details

System ID Private Priority Status Summary Last Updated
Icedtea Bugzilla 2308 0 None None None 2019-07-22 02:46:16 UTC
Red Hat Product Errata RHEA-2015:2177 0 normal SHIPPED_LIVE java-1.7.0-openjdk bug fix and enhancement update 2015-11-19 07:52:28 UTC

Description Alon Bar-Lev 2015-03-19 11:47:46 UTC
Created attachment 1003813 [details]

Existence of ipv6 resolver address cases jndi resolver to fail, due to incorrect parsing of /etc/resolv.conf.

In linux[1] the format should be:

nameserver ipv4|ipv6

While Java expects the *bsd (and may be others) style of:

nameserver ipv4|\[ipv6\][:port]

I checked glibc's libresolv and clearly the [] nor port are unexpected.

Java parse implementation[3] tries to extract port after ']'.

Effected versions are probably since ever(?) including java-8.

OpenJDK bug was opened long time ago[4].

Attached reproduce program.

Exception in thread "main" java.lang.NumberFormatException: For input string: ":1"
        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 com.sun.jndi.dns.Resolver.<init>(Resolver.java:61)

[1] http://linux.die.net/man/5/resolv.conf
[2] http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/resolv.conf.5?query=resolv.conf&sec=5
[3] http://www.docjar.com/html/api/com/sun/jndi/dns/DnsClient.java.html#111
[4] https://bugs.openjdk.java.net/browse/JDK-6991580?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Comment 2 Deepak Bhole 2015-03-19 13:46:39 UTC
Hi, what are the contents of your resolv.conf?

Comment 3 Alon Bar-Lev 2015-03-19 14:04:49 UTC
(In reply to Deepak Bhole from comment #2)
> Hi, what are the contents of your resolv.conf?

you can put any ipv6, simple example:

nameserver ::1

Comment 4 Stanislav Baiduzhyi 2015-04-16 09:16:50 UTC
Severin already fixed the root issue in another bug.

Comment 5 Stanislav Baiduzhyi 2015-06-23 14:41:54 UTC

*** This bug has been marked as a duplicate of bug 1210739 ***

Comment 6 Andrew John Hughes 2015-06-23 15:54:31 UTC
The other bug is a Fedora java-1.8.0-openjdk bug. This is for java-1.7.0-openjdk on RHEL 7.1. Re-opening.

Comment 7 Andrew John Hughes 2015-06-23 16:06:33 UTC

$ /usr/lib/jvm/icedtea-7/bin/java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (Gentoo package icedtea-
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

$ cat /etc/resolv.conf
nameserver ::1

$ /usr/lib/jvm/icedtea-7/bin/java Resolve
Resolving: lt2dka00.grid.hep.ph.ic.ac.uk
Exception in thread "main" java.lang.NumberFormatException: For input string: ":1"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:492)
	at java.lang.Integer.parseInt(Integer.java:527)
	at com.sun.jndi.dns.DnsClient.<init>(DnsClient.java:125)
	at com.sun.jndi.dns.Resolver.<init>(Resolver.java:61)
	at com.sun.jndi.dns.DnsContext.getResolver(DnsContext.java:570)
	at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:430)
	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:231)
	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:139)
	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:127)
	at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)
	at Resolve.main(Resolve.java:16)

With 2.6.0pre23, where 6991580 is applied:

$ /home/andrew/build/icedtea7/bin/java -version
java version "1.7.0_80"
OpenJDK Runtime Environment (IcedTea 2.6.0pre23+r909fa12f498c+) (Gentoo build 1.7.0_80-b32)
OpenJDK 64-Bit Server VM (build 24.80-b11, mixed mode)

$ /home/andrew/build/icedtea7/bin/java Resolve
Resolving: lt2dka00.grid.hep.ph.ic.ac.uk
{aaaa=AAAA: 2001:630:12:580::101}

Comment 13 errata-xmlrpc 2015-11-19 03:55:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.