diff options
author | Steve Ellcey <sellcey@mips.com> | 2015-06-01 09:00:05 -0700 |
---|---|---|
committer | Steve Ellcey <sellcey@mips.com> | 2015-06-01 09:00:05 -0700 |
commit | 2483fa850f86a2edec705aaeb2ca84414d6e1367 (patch) | |
tree | d237d18f7c2b188491ed51fffe66e7d6f8236736 /resolv | |
parent | fd57d826c62c8eaaedcda49a1367b6604db775f7 (diff) | |
download | glibc-2483fa850f86a2edec705aaeb2ca84414d6e1367.tar.gz glibc-2483fa850f86a2edec705aaeb2ca84414d6e1367.tar.xz glibc-2483fa850f86a2edec705aaeb2ca84414d6e1367.zip |
* resolv/res_hconf.c (_res_hconf_reorder_addrs): Use a union to
copy data from cur_ifr->ifr_addr and cur_ifr->ifr_netmask.
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/res_hconf.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c index 73942e8119..b9c229d24a 100644 --- a/resolv/res_hconf.c +++ b/resolv/res_hconf.c @@ -439,18 +439,24 @@ _res_hconf_reorder_addrs (struct hostent *hp) for (cur_ifr = ifr, i = 0; i < num; cur_ifr = __if_nextreq (cur_ifr), ++i) { + union + { + struct sockaddr sa; + struct sockaddr_in sin; + } ss; + if (cur_ifr->ifr_addr.sa_family != AF_INET) continue; 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; + ss.sa = cur_ifr->ifr_addr; + ifaddrs[new_num_ifs].u.ipv4.addr = ss.sin.sin_addr.s_addr; if (__ioctl (sd, SIOCGIFNETMASK, cur_ifr) < 0) continue; - ifaddrs[new_num_ifs].u.ipv4.mask = - ((struct sockaddr_in *) &cur_ifr->ifr_netmask)->sin_addr.s_addr; + ss.sa = cur_ifr->ifr_netmask; + ifaddrs[new_num_ifs].u.ipv4.mask = ss.sin.sin_addr.s_addr; /* Now we're committed to this entry. */ ++new_num_ifs; |