Hi all,
This commit fixes a bug whereby IPv6 addresses with a one-digit first
component would caught as errors by SocketPermission's constructor.
Cheers,
Gary
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8594
diff -u -r1.8594 ChangeLog
--- ChangeLog 22 Sep 2006 12:27:10 -0000 1.8594
+++ ChangeLog 22 Sep 2006 13:23:56 -0000
@@ -1,3 +1,9 @@
+2006-09-22 Gary Benson <[EMAIL PROTECTED]>
+
+ * java/net/SocketPermission.java
+ (processHostport): Cope with IPv6 addresses with a
+ one-digit first component.
+
2006-09-22 Roman Kennke <[EMAIL PROTECTED]>
* java/awt/Component.java
Index: java/net/SocketPermission.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.23
diff -u -r1.23 SocketPermission.java
--- java/net/SocketPermission.java 14 Sep 2006 13:43:40 -0000 1.23
+++ java/net/SocketPermission.java 22 Sep 2006 13:23:56 -0000
@@ -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);