FYI: SocketPermission bugfix

Gary Benson gbenson@redhat.com
Thu Oct 5 09:35:00 GMT 2006


Hi all,

This commit fixes a bug that probably breaks Azureus amongst others
when a security manager is enabled.

Cheers,
Gary
-------------- next part --------------
Index: classpath/ChangeLog.gcj
===================================================================
--- classpath/ChangeLog.gcj	(revision 117452)
+++ classpath/ChangeLog.gcj	(working copy)
@@ -1,3 +1,9 @@
+2006-10-05  Gary Benson  <gbenson@redhat.com>
+
+	* java/net/SocketPermission.java
+	(processHostport): Cope with IPv6 addresses with a
+	one-digit first component.
+
 2006-09-25  Tom Tromey  <tromey@redhat.com>
 
 	* native/jni/gconf-peer/Makefile.in: Rebuilt.
Index: classpath/java/net/SocketPermission.java
===================================================================
--- classpath/java/net/SocketPermission.java	(revision 117452)
+++ classpath/java/net/SocketPermission.java	(working copy)
@@ -193,16 +193,19 @@
     if (hostport.charAt(0) == '[')
       return hostport;
 
-    int colons = 0, last_colon = 0;
+    int colons = 0;
+    boolean colon_allowed = true;
     for (int i = 0; i < hostport.length(); i++)
       {
 	if (hostport.charAt(i) == ':')
 	  {
-	    if (i - last_colon == 1)
+	    if (!colon_allowed)
 	      throw new IllegalArgumentException("Ambiguous hostport part");
 	    colons++;
-	    last_colon = i;
+	    colon_allowed = false;
 	  }
+	else
+	  colon_allowed = true;
       }
 
     switch (colons)
@@ -218,6 +221,7 @@
 
       case 8:
 	// an IPv6 address with ports
+	int last_colon = hostport.lastIndexOf(':');
 	return "[" + hostport.substring(0, last_colon) + "]"
 	  + hostport.substring(last_colon);
 


More information about the Java-patches mailing list