Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1203666

Summary: /etc/resolv.conf nameserver with ipv6 address causes jndi NumberFormatException
Product: Red Hat Enterprise Linux 7 Reporter: Alon Bar-Lev <alonbl>
Component: java-1.7.0-openjdkAssignee: Andrew John Hughes <ahughes>
Status: CLOSED ERRATA QA Contact: Lukáš Zachar <lzachar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: ahughes, dbhole, iheim, sbaiduzh, simon.fayer05
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: https://bugs.openjdk.java.net/browse/JDK-6991580?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 03:55:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1210739    
Bug Blocks:    
Attachments:
Description Flags
Resolve.java none

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

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
Reproduced:

$ /usr/lib/jvm/icedtea-7/bin/java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (Gentoo package icedtea-7.2.5.5)
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.

https://rhn.redhat.com/errata/RHEA-2015-2177.html