This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Error:bsd_bind
- From: "reji" <reji at codito dot com>
- To: <ecos-patches at sources dot redhat dot com>
- Date: Tue, 14 Oct 2003 21:09:08 +0530
- Subject: Error:bsd_bind
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 .
Patch
static int
bsd_bind(cyg_file *fp, const sockaddr *sa, socklen_t len)
{
sockaddr *copy_sa;
int error=-1;
copy_sa=(sockaddr *)malloc(sizeof(struct sockaddr),M_TEMP,M_WAITOK);
if (!copy_sa)
return (error);
memcpy((void *)copy_sa,(void *)sa,sizeof(struct sockaddr));
error = sobind((struct socket *)fp->f_data, copy_sa,0);
free(copy_sa,M_TEMP);
return error;
}
RejiThomas
Codito Technologies