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: [PATCH] Handle null host in Socket.bind().


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);
     }

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