[asterisk-dev] [asterisk-commits] simon.perreault: branch group/v6-new r274766 - /team/group/v6-new/main/

Tilghman Lesher tlesher at digium.com
Thu Jul 8 11:27:25 CDT 2010


On Thursday 08 July 2010 10:40:15 Kevin P. Fleming wrote:
> On 07/08/2010 10:34 AM, SVN commits to the Asterisk project wrote:
> > Author: simon.perreault
> > Date: Thu Jul  8 10:34:30 2010
> > New Revision: 274766
> >
> > URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=274766
> > Log:
> > Fixed another pointer issue
> >
> > Modified:
> >     team/group/v6-new/main/netsock2.c
> >
> > Modified: team/group/v6-new/main/netsock2.c
> > URL:
> > http://svnview.digium.com/svn/asterisk/team/group/v6-new/main/netsock2.c?
> >view=diff&rev=274766&r1=274765&r2=274766
> > =========================================================================
> >===== --- team/group/v6-new/main/netsock2.c (original)
> > +++ team/group/v6-new/main/netsock2.c Thu Jul  8 10:34:30 2010
> > @@ -489,7 +489,7 @@
> >
> >  void ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct
> > sockaddr_in *sin) {
> > -	memcpy(&addr->ss, &sin, sizeof(*sin));
> > +	memcpy(&addr->ss, sin, sizeof(*sin));
> >
> >  	if (addr->ss.ss_family != AF_INET) {
> >  		ast_log(LOG_DEBUG, "Address family is not AF_INET\n");
>
> Problems of this type could be avoided completely by making the
> ast_sockaddr structure 'ss' member a union of the various types of
> sockaddr structures you intend to store there and then using direct
> structure assignments instead of memcpy().

I had proposed that before in a code review, and he replied that it was
intentionally ugly, since the port numbers were not aligned with one another
in the union, thus making a port assignment to the wrong address type a
coding error.  I think we could get around this by adding a header to the IPv4
struct within the union, such that the port number of both addresses align.

-- 
Tilghman Lesher
Digium, Inc. | Senior Software Developer
twitter: Corydon76 | IRC: Corydon76-dig (Freenode)
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list