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: Account for possible null laddr in Socket.java


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Sonntag, 15. Juni 2003 20:48 schrieb Mohan Embar:
> Michael,
>
> This fixes Socket.Socket(InetAddress, int, InetAddress, int,
> boolean) to account for a possible laddr==null through a call from
> another overloaded constructor, such as Socket.Socket(InetAddress,
> int).

> Index: java/net/Socket.java
> ===================================================================
> RCS file: /cvsroot/gcc/gcc/libjava/java/net/Socket.java,v
> retrieving revision 1.23
> diff -u -2 -r1.23 Socket.java
> --- java/net/Socket.java	8 Jun 2003 10:12:09 -0000	1.23
> +++ java/net/Socket.java	15 Jun 2003 18:34:40 -0000
> @@ -291,5 +291,7 @@
>
>      // bind/connect socket
> -    bind (new InetSocketAddress (laddr, lport));
> +    SocketAddress lbindpoint =
> +      laddr == null ? null : new InetSocketAddress (laddr, lport);
> +    bind (lbindpoint);
>      connect (new InetSocketAddress (raddr, rport));

Yes, this part of the code is a problem. Sorry that I have to say this 
but I think your patch is half-hearted. raddr can be null too ...
I have attached a rewritten patch. Please review and comment.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+7bqZWSOgCCdjSDsRArhIAJ9s0oWLPpcxjzTo+rHeVU3+ea64AgCeKkM3
CW8N2+swVxEQtiqwceTmfJw=
=iVRY
-----END PGP SIGNATURE-----
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.23
diff -u -b -B -r1.23 Socket.java
--- java/net/Socket.java	8 Jun 2003 10:12:09 -0000	1.23
+++ java/net/Socket.java	16 Jun 2003 12:32:34 -0000
@@ -289,9 +298,15 @@
     if (sm != null)
       sm.checkConnect(raddr.getHostName(), rport);
 
-    // bind/connect socket
-    bind (new InetSocketAddress (laddr, lport));
-    connect (new InetSocketAddress (raddr, rport));
+    // bind socket
+    SocketAddress bindaddr =
+      laddr == null ? null : new InetSocketAddress (laddr, lport);
+    bind (bindaddr);
+    
+    // connect socket
+    SocketAddress connectaddr =
+      raddr == null ? null : new InetSocketAddress (raddr, rport);
+    connect (connectaddr);
 
     // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
     // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as

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