On Thu, Dec 25, 2003 at 06:18:51PM +0100, Michael Koch wrote:
> On Wed, Dec 24, 2003 at 04:40:34PM +0100, Guilhem Lavaux wrote:
> > Hi,
> > 
> > It seems that nobody checks for null internet address in ServerSocket.bind.
> > Here is a quick fix which should prevent calling a native method with a 
> > null address argument.
> > 
> > Regards,
> > Guilhem.
> > 
> > ChangeLog:
> > 
> > 2003-12-24  Guilhem Lavaux <[EMAIL PROTECTED]>
> > 
> >    * java/net/ServerSocket.java (bind): Check whether the address is null.
> > 
> > P.S.: I hope it can be applied to gcj (I've checked that the same code 
> > is present there), the patch has been built upon kaffe's CVS.
> 
> Two things: the patch is missing and the code uses a "instanceof"
> operator which implicitly checks for "null".

After talking with guilhem on irc I got the problem and wrote the
attached patch. I commited it to trunk already.

Mark: Can you please commit this to classpath ?


Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2485
diff -u -b -B -r1.2485 ChangeLog
--- ChangeLog   23 Dec 2003 22:06:01 -0000      1.2485
+++ ChangeLog   25 Dec 2003 17:29:14 -0000
@@ -1,3 +1,9 @@
+2003-12-25  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/net/ServerSocket.java bind():
+       If InetSocketAddress.getAddress() returns "null" use "0.0.0.0" as
+       address to bind to.
+
 2003-12-23  Guilhem Lavaux <[EMAIL PROTECTED]>
 
        * java/io/ObjectInputStream.java
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.32
diff -u -b -B -r1.32 ServerSocket.java
--- java/net/ServerSocket.java  9 Dec 2003 15:39:23 -0000       1.32
+++ java/net/ServerSocket.java  25 Dec 2003 17:29:14 -0000
@@ -226,9 +226,15 @@
     if (s != null)
       s.checkListen (tmp.getPort ());
 
+    InetAddress addr = tmp.getAddress();
+    
+    // Initialize addr with 0.0.0.0.
+    if (addr == null)
+      addr = InetAddress.ANY_IF;
+    
     try
       {
-       impl.bind (tmp.getAddress (), tmp.getPort ());
+       impl.bind(addr, tmp.getPort());
        impl.listen(backlog);
        bound = true;
       }
_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to