This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: NetworkInterface.getInetAddresses() fix


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... ?

Ok, I missed the line in the SocketPermission javadoc that says "The
full uncompressed form of an IPv6 literal address is also valid", so
adding the brackets should not be necessary here (assuming that
Inet6Address.getHostAddress() always returns addresses in the full
uncompressed form of course ;)).

I had a play with a couple of proprietary JVMs and it seems that they
handle unbracketed IPv6 addresses by bracketing them at <init> time,
so I wrote a patch that makes us do that too.  Does this seem ok?

Cheers,
Gary

Attachment: patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]