United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7041200 java.net.InterfaceAddress's equals method may throw NPE
JDK-7041200 : java.net.InterfaceAddress's equals method may throw NPE

Details
Type:
Bug
Submit Date:
2011-05-02
Status:
Resolved
Updated Date:
2011-09-08
Project Name:
JDK
Resolved Date:
2011-05-31
Component:
core-libs
OS:
generic
Sub-Component:
java.net
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6u26-rev (b22)

Related Reports
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
InterfaceAddress.equals contains this:

if ((address != null & cmp.address == null) ||
    (!address.equals(cmp.address)))
    return false;
if ((broadcast != null & cmp.broadcast == null) ||
    (!broadcast.equals(cmp.broadcast)))
    return false;

if address == null, or broadcast == null, NPE will be thrown.  broadcast ==
null can be tested by running this test:

try {
   Enumeration<NetworkInterface> networkInterfaces =
      NetworkInterface.getNetworkInterfaces();

   while (networkInterfaces.hasMoreElements()) {
      NetworkInterface networkInterface = networkInterfaces.nextElement();

      List<InterfaceAddress> interfaceAddresses =
         networkInterface.getInterfaceAddresses();

      for (InterfaceAddress interfaceAddress : interfaceAddresses) {
         interfaceAddress.equals(interfaceAddress);
      }
   }
} catch (SocketException ex) {
   ex.printStackTrace();
}

When the loopback interface address is reached, NPE will be thrown for the
broadcast test.  I'm not sure if you can get an interface address with a null
address.

This has been fixed in JDK 7.

                                    

Comments
EVALUATION

Appears to be a dup of 6628576.
                                     
2011-05-03



Hardware and Software, Engineered to Work Together