From f930796d752235b4f23957a7c663862df5609d42 Mon Sep 17 00:00:00 2001 From: Gary Benson Date: Fri, 22 Sep 2006 13:24:32 +0000 Subject: 2006-09-22 Gary Benson * java/net/SocketPermission.java (processHostport): Cope with IPv6 addresses with a one-digit first component. --- java/net/SocketPermission.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'java/net') diff --git a/java/net/SocketPermission.java b/java/net/SocketPermission.java index 2d6343dc5..64885438a 100644 --- a/java/net/SocketPermission.java +++ b/java/net/SocketPermission.java @@ -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); -- cgit v1.2.1