This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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] Fix strict-aliasing warning in resolv/res_hconf.c


On 05/27/2015 11:19 AM, Pedro Alves wrote:

> Without adding a new union member, isn't the simplest to just take a
> copy step?  The interface already clearly assumes that a sockaddr_in
> fits in a sockaddr.  Something like:
> 
>               union
>                 {
>                   struct sockaddr sa;
>                   struct sockaddr_in sin;
>                 } ss;
> 
> -  	      ifaddrs[new_num_ifs].u.ipv4.addr =
> -		((struct sockaddr_in *) &cur_ifr->ifr_addr)->sin_addr.s_addr;
> +             ss.sa = cur_ifr->ifr_addr;
> +	      ifaddrs[new_num_ifs].u.ipv4.addr = ss.sin.sin_addr.s_addr;
> 
> etc.

I misread this proposal.  I now think this is a possible fix, and a very
conservative one at that.

-- 
Florian Weimer / Red Hat Product Security


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