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 - /etc/resolv.conf nameserver with ipv6 address causes jndi NumberFormatException
Summary: /etc/resolv.conf nameserver with ipv6 address causes jndi NumberFormatException
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: java-1.7.0-openjdk
Version: 7.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Andrew John Hughes
QA Contact: Lukáš Zachar
URL: https://bugs.openjdk.java.net/browse/...
Whiteboard:
Depends On: 1210739
Blocks:
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:
Environment:
Last Closed: 2015-11-19 03:55:07 UTC
Target Upstream Version:
Embargoed:


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


Links
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]
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


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