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: Fix InetAddress.getByName and loopback issues


Oops, thanks for fixing this. I didn't notice it because this particular code is only build on platforms that are #ifndef HAVE_GETHOSTBYNAME_R.

Regards

Bryce


On Aug 13, 2004, at 10:41 PM, Andreas Tobler wrote:


Bryce McKinlay wrote:

Bryce McKinlay wrote:
Passing null to InetAddress.getByName() and getAllByName should return the loopback InetAddress. Its possible to do this without the normal security check - passing a null argument to SecurityManager would be a NullPointerException. This also cleans up the security checks - lookup() does not need to do a check becuase the public methods that call it will have done it already. In the getByName() case, we were actually doing the check 3 times - once in getByName, once in getAllByName, and then again in lookup.
I also checked in some mauve tests for this.

You forgot natInetAddressPosix and Win32.


Patch attached.

Greets
Andreas

2004-08-14 Andreas Tobler <a.tobler@schweiz.ch>

	* java/net/natInetAddressPosix.cc (lookup): Reflect rename of
	localhostAddress to loopbackAddress.
	* java/net/natInetAddressWin32.cc (lookup): Likewise.
Index: java/net/natInetAddressWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natInetAddressWin32.cc,v
retrieving revision 1.6
diff -u -r1.6 natInetAddressWin32.cc
--- java/net/natInetAddressWin32.cc	30 Nov 2003 21:02:56 -0000	1.6
+++ java/net/natInetAddressWin32.cc	14 Aug 2004 02:37:36 -0000
@@ -60,7 +60,7 @@

       // FIXME: this is insufficient if some other piece of code calls
       // this gethostbyname.
-      JvSynchronize sync (java::net::InetAddress::localhostAddress);
+      JvSynchronize sync (java::net::InetAddress::loopbackAddress);
       hptr = gethostbyname (hostname);
     }
   else
@@ -87,7 +87,7 @@

       // FIXME: this is insufficient if some other piece of code calls
       // this gethostbyaddr.
-      JvSynchronize sync (java::net::InetAddress::localhostAddress);
+      JvSynchronize sync (java::net::InetAddress::loopbackAddress);
       hptr = gethostbyaddr (val, len, type);
     }
   if (hptr != NULL)
Index: java/net/natInetAddressPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natInetAddressPosix.cc,v
retrieving revision 1.4
diff -u -r1.4 natInetAddressPosix.cc
--- java/net/natInetAddressPosix.cc	13 Aug 2004 22:17:34 -0000	1.4
+++ java/net/natInetAddressPosix.cc	14 Aug 2004 02:37:36 -0000
@@ -167,7 +167,7 @@
 #else
       // FIXME: this is insufficient if some other piece of code calls
       // this gethostbyname.
-      JvSynchronize sync (java::net::InetAddress::localhostAddress);
+      JvSynchronize sync (java::net::InetAddress::loopbackAddress);
       hptr = gethostbyname (hostname);
 #endif /* HAVE_GETHOSTBYNAME_R */
     }
@@ -221,7 +221,7 @@
 #else /* HAVE_GETHOSTBYADDR_R */
       // FIXME: this is insufficient if some other piece of code calls
       // this gethostbyaddr.
-      JvSynchronize sync (java::net::InetAddress::localhostAddress);
+      JvSynchronize sync (java::net::InetAddress::loopbackAddress);
       hptr = gethostbyaddr (val, len, type);
 #endif /* HAVE_GETHOSTBYADDR_R */
     }


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