2006-10-05 Gary Benson <gbenson@redhat.com>
authorGary Benson <gbenson@redhat.com>
Thu, 5 Oct 2006 09:32:57 +0000 (09:32 +0000)
committerGary Benson <gary@gcc.gnu.org>
Thu, 5 Oct 2006 09:32:57 +0000 (09:32 +0000)
* java/net/SocketPermission.java
(processHostport): Cope with IPv6 addresses with a
one-digit first component.

From-SVN: r117454

libjava/classpath/ChangeLog.gcj
libjava/classpath/java/net/SocketPermission.java

index 91948d1fe928278a862a28e0c1aec475cb1697be..56d1cb91144da9ba4c78de714916bb37fff984b2 100644 (file)
@@ -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 2d6343dc570e41be5414b05678bb055dcd049dfd..64885438aed51b5df6c6542ec216106c789617f9 100644 (file)
@@ -193,16 +193,19 @@ public final class SocketPermission extends Permission implements Serializable
     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 @@ public final class SocketPermission extends Permission implements Serializable
 
       case 8:
        // an IPv6 address with ports
+       int last_colon = hostport.lastIndexOf(':');
        return "[" + hostport.substring(0, last_colon) + "]"
          + hostport.substring(last_colon);