United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4748544 Spec for InetAddress.getByAddress(host,addr) does not go with implementation
JDK-4748544 : Spec for InetAddress.getByAddress(host,addr) does not go with implementation

Details
Type:
Bug
Submit Date:
2002-09-17
Status:
Closed
Updated Date:
2004-09-01
Project Name:
JDK
Resolved Date:
2003-11-03
Component:
core-libs
OS:
generic
Sub-Component:
java.net
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.1,5.0
Fixed Versions:
5.0 (b28)

Related Reports

Sub Tasks

Description

Name: dfR10049			Date: 09/17/2002


Javadoc states for java.net.InetAddress.getByAddress(String host, byte[] addr):

    For host specified in literal IPv6 address, either the form defined in RFC 2732 
    or the literal IPv6  address format defined in RFC 2373 is accepted.

But getByAddress(String host, byte[] addr) does not check for the format of 'host'.
It allows to create InetAddress with "1234::2345::3456" hostname.

The following test demonstrates the bug:
--------- Test.java ----------
import java.net.*;

public class Test {

    public static void main(String args[]) {
 
         String host = "1234::2345::3456";
         byte[] addr = { 0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
        
         try {
            InetAddress testAddr = InetAddress.getByAddress(host, addr);
            System.out.println("Test failed with: " + host);
            System.out.println("Created: " + testAddr);
         } catch( UnknownHostException e ) {
            System.out.println("Test passed");
         }
    }

}
-----------------------------------------
output from the test:

#> java Test
Test failed with: 1234::2345::3456
Created: 1234::2345::3456/1:203:405:607:809:a0b:c0d:e0f

I see two possible ways this bug may be fixed:
   - getByAddress(host, addr) will check the format of 'host'
   - assertion about acceptable hosts will be removed from spec 

======================================================================

                                    

Comments
EVALUATION

Yes, the spec needs to be clarified either way.
There is a plan to add some checks in tiger to validite the given hostname,
before looking up the name server. 
This will be worked out in tiger along with other specification issues with InetAddress.

###@###.### 2002-10-28

Actually we need to update the javadoc. There never an intent to do any check in there, or name service lookup for that matter. But this should be specified in the doc. Will do so for Tiger.

###@###.### 2003-06-27
                                     
2003-06-27
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger
tiger-beta

FIXED IN:
tiger-beta

INTEGRATED IN:
tiger-b28
tiger-beta

VERIFIED IN:
tiger-rc


                                     
2004-09-13



Hardware and Software, Engineered to Work Together