FYI: NetworkInterface.getInetAddresses() fix

Gary Benson gbenson@redhat.com
Fri Aug 25 08:16:00 GMT 2006


Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
> 
> Gary> This commit makes NetworkInterface.getInetAddresses()
> Gary> bracket IPv6 addresses before calling SecurityManager.
> Gary> checkConnect() with them.  This fixes
> Gary> http://gcc.gnu.org/ml/java/2006-08/msg00082.html.
> 
> I'm curious about one aspect of this patch...
> 
> Gary> +	    String hostAddress = addr.getHostAddress();
> Gary> +	    if (addr instanceof Inet6Address)
> Gary> +	      hostAddress = "[" + hostAddress + "]";
> 
> This is un-OO-like, which raises a warning flag for me.
> I was wondering whether the brackets ought to be added in
> Inet6Address.getHostAddress... ?

Inet6Address.getHostAddress() definitly doesn't add the brackets --
see the javadoc for java.net.SocketPermission.  However, it seems that
proprietary JVMs support the creation of SocketPermissions with non-
bracketed IPv6 addresses, an extension of the spec.  So I guess we
ought to be doing that too :/

Cheers,
Gary



More information about the Java-patches mailing list