FYI: NetworkInterface.getInetAddresses() fix

Gary Benson gbenson@redhat.com
Thu Aug 24 14:30:00 GMT 2006


Hi all,

This commit makes NetworkInterface.getInetAddresses() bracket IPv6
addresses before calling SecurityManager.checkConnect() with them.
This fixes http://gcc.gnu.org/ml/java/2006-08/msg00082.html.

Cheers,
Gary
-------------- next part --------------
Index: classpath/ChangeLog.gcj
===================================================================
--- classpath/ChangeLog.gcj	(revision 116373)
+++ classpath/ChangeLog.gcj	(working copy)
@@ -1,3 +1,8 @@
+2006-08-24  Gary Benson  <gbenson@redhat.com>
+
+	* java/net/NetworkInterface.java (getInetAddresses): Bracket IPv6
+	addresses.
+
 2006-08-18  Roger Sayle  <roger@eyesopen.com>
 
 	* scripts/check_jni_methods.sh: Don't use the "set -C" command
Index: classpath/java/net/NetworkInterface.java
===================================================================
--- classpath/java/net/NetworkInterface.java	(revision 116373)
+++ classpath/java/net/NetworkInterface.java	(working copy)
@@ -112,7 +112,10 @@
 	InetAddress addr = (InetAddress) addresses.nextElement();
 	try
 	  {
-	    s.checkConnect(addr.getHostAddress(), 58000);
+	    String hostAddress = addr.getHostAddress();
+	    if (addr instanceof Inet6Address)
+	      hostAddress = "[" + hostAddress + "]";
+	    s.checkConnect(hostAddress, 58000);
 	    tmpInetAddresses.add(addr);
 	  }
 	catch (SecurityException e)


More information about the Java-patches mailing list