This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] Handle null host in Socket.bind().
- From: David Daney <ddaney at avtrex dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Mon, 04 Feb 2008 22:30:16 -0800
- Subject: Re: [PATCH] Handle null host in Socket.bind().
- References: <47A7D16F.4040703@avtrex.com>
David Daney wrote:
> This is a problem I noticed while looking at something else.
>
> We are not handling a null host value which should bind to INADDR_ANY.
> We would get a NPE instead.
>
> OK for 4.3 if testing shows no problems?
>
> 2008-02-04 David Daney <ddaney@avtrex.com>
>
> * gnu/java/net/natPlainSocketImplPosix.cc(bind): Handle null
> host.
>
Patch withdrawn.
Testing reveals that a null host value is handled in InetSocketAdress'
constructor. The checks in natPlainSocketImplPosix.cc are redundant,
but not harmful.
In stage 1 I will test this patch:
2008-02-04 David Daney <ddaney@avtrex.com>
* gnu/java/net/natPlainSocketImplPosix.cc (bind): Remove check for
null host.
Index: gnu/java/net/natPlainSocketImplPosix.cc
===================================================================
--- gnu/java/net/natPlainSocketImplPosix.cc (revision 132105)
+++ gnu/java/net/natPlainSocketImplPosix.cc (working copy)
@@ -99,12 +99,7 @@ gnu::java::net::PlainSocketImpl::bind (:
if (len == 4)
{
u.address.sin_family = AF_INET;
-
- if (host != NULL)
- memcpy (&u.address.sin_addr, bytes, len);
- else
- u.address.sin_addr.s_addr = htonl (INADDR_ANY);
-
+ memcpy (&u.address.sin_addr, bytes, len);
len = sizeof (struct sockaddr_in);
u.address.sin_port = htons (lport);
}