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:
> On 05/20/2015 05:27 PM, Steve Ellcey wrote:
> 
>> diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
>> index 73942e8..3b05287 100644
>> --- a/resolv/res_hconf.c
>> +++ b/resolv/res_hconf.c
>> @@ -444,13 +444,13 @@ _res_hconf_reorder_addrs (struct hostent *hp)
>>  
>>  	      ifaddrs[new_num_ifs].addrtype = AF_INET;
>>  	      ifaddrs[new_num_ifs].u.ipv4.addr =
>> -		((struct sockaddr_in *) &cur_ifr->ifr_addr)->sin_addr.s_addr;
>> +		cur_ifr->ifr_addr_in.sin_addr.s_addr;
> 
> Without adding a new union member, isn't the simplest to just take a
> copy step?

I think it's still undefined behavior.

> etc.  Maybe the compiler even elides the copying.

If it does, we are back to square one, I fear.

-- 
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]