Commit 366f1622 by Gary Benson Committed by Gary Benson

2006-09-05 Gary Benson <gbenson@redhat.com>

	* java/net/SocketPermission.java
	(maybeBracketIPv6Address): Renamed to processHostport.
	(processHostport): Also translate "" to "localhost".
	(setHostPort): Remove special cases for empty hostport and for
	extra colons in hostport (processHostport handles these now).

From-SVN: r116694
parent fd89bc3f
2006-09-05 Gary Benson <gbenson@redhat.com>
* java/net/SocketPermission.java
(maybeBracketIPv6Address): Renamed to processHostport.
(processHostport): Also translate "" to "localhost".
(setHostPort): Remove special cases for empty hostport and for
extra colons in hostport (processHostport handles these now).
2006-08-31 Keith Seitz <keiths@redhat.com> 2006-08-31 Keith Seitz <keiths@redhat.com>
* include/jvmti.h: Update from Classpath to get latest fixes and * include/jvmti.h: Update from Classpath to get latest fixes and
......
...@@ -164,21 +164,26 @@ public final class SocketPermission extends Permission implements Serializable ...@@ -164,21 +164,26 @@ public final class SocketPermission extends Permission implements Serializable
*/ */
public SocketPermission(String hostport, String actions) public SocketPermission(String hostport, String actions)
{ {
super(maybeBracketIPv6Address(hostport)); super(processHostport(hostport));
setHostPort(getName()); setHostPort(getName());
setActions(actions); setActions(actions);
} }
/** /**
* IPv6 addresses in the hostport must either be enclosed by * There are two cases in which hostport needs rewriting before
* "[" and "]" or be specified in the full uncompressed form. * being passed to the superclass constructor. If hostport is an
* In the latter case proprietary JVMs will quote the address * empty string then it is substituted with "localhost". And if
* with "[" and "]", so we do to. * the host part of hostport is a literal IPv6 address in the full
* uncompressed form not enclosed with "[" and "]" then we enclose
* it with them.
*/ */
private static String maybeBracketIPv6Address(String hostport) private static String processHostport(String hostport)
{ {
if (hostport.length() == 0 || hostport.charAt(0) == '[') if (hostport.length() == 0)
return "localhost";
if (hostport.charAt(0) == '[')
return hostport; return hostport;
int colons = 0, last_colon = 0; int colons = 0, last_colon = 0;
...@@ -221,11 +226,7 @@ public final class SocketPermission extends Permission implements Serializable ...@@ -221,11 +226,7 @@ public final class SocketPermission extends Permission implements Serializable
{ {
// Split into host and ports // Split into host and ports
String ports; String ports;
if (hostport.length() == 0) if (hostport.charAt(0) == '[')
{
host = ports = "";
}
else if (hostport.charAt(0) == '[')
{ {
// host is a bracketed IPv6 address // host is a bracketed IPv6 address
int end = hostport.indexOf("]"); int end = hostport.indexOf("]");
...@@ -255,8 +256,6 @@ public final class SocketPermission extends Permission implements Serializable ...@@ -255,8 +256,6 @@ public final class SocketPermission extends Permission implements Serializable
ports = hostport.substring(sep + 1); ports = hostport.substring(sep + 1);
} }
} }
if (ports.indexOf(":") != -1)
throw new IllegalArgumentException("Unexpected ':'");
// Parse and validate the ports // Parse and validate the ports
if (ports.length() == 0) if (ports.length() == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment