This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos 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: Error:bsd_bind


On Tue, Oct 14, 2003 at 09:09:08PM +0530, reji wrote:
> Problem  in bsd_bind(packages/net/bsd_tcpip/current/src/sys/kern/sockio.c)
> 
>  bsd_bind(cyg_file *fp, const sockaddr *sa, socklen_t len)
>  {
>      int error;
> 
>      error = sobind((struct socket *)fp->f_data, (sockaddr *)sa, 0);
>      return error;
>  }
> 
> The sa which was declared to be a const is  passed to sobind without making
> a copy.
> In the call to in_pcbbind ,in_pcbbind zeroes out  the port number in the
> socket address structure for passing it to ifa_ifwithaddr for doing a
> binary comparision of the whole structure .

Thanks for the bug report. Here is the fix i committed.

       Andrew

Index: io/fileio/current//ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/ChangeLog,v
retrieving revision 1.33
diff -u -r1.33 ChangeLog
--- io/fileio/current//ChangeLog        6 Oct 2003 18:45:22 -0000       1.33
+++ io/fileio/current//ChangeLog        16 Oct 2003 07:53:09 -0000
@@ -1,3 +1,9 @@
+2003-10-16  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+       * src/socket.cxx (bind): Pass a copy of the socket address so the
+       stack can modify it without changing the users copy. Bug found by
+       reji@codito.com.
+
 2003-10-06  Andrew Lunn  <andrew.lunn@ascom.ch>
 
        * src/fio.h (CYG_FILEIO_SIGMASK_SET): Fixed a compiler warning
Index: io/fileio/current//src/socket.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/socket.cxx,v
retrieving revision 1.7
diff -u -r1.7 socket.cxx
--- io/fileio/current//src/socket.cxx   13 Jul 2003 13:25:27 -0000      1.7
+++ io/fileio/current//src/socket.cxx   16 Oct 2003 07:53:10 -0000
@@ -267,7 +267,8 @@
 
     int ret = 0;
     cyg_file *fp;
-    
+    struct sockaddr sa2 = *sa;
+
     fp = cyg_fp_get( s );
 
     if( fp == NULL )
@@ -279,7 +280,7 @@
 
         LOCK_SOCKET( fp );
 
-        ret = ops->bind( fp, sa, len );
+        ret = ops->bind( fp, &sa2, len );
 
         UNLOCK_SOCKET( fp );
 


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