From: Steve Ellcey Date: Mon, 1 Jun 2015 16:00:05 +0000 (-0700) Subject: * resolv/res_hconf.c (_res_hconf_reorder_addrs): Use a union to X-Git-Tag: upstream/2.30~6001 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2483fa850f86a2edec705aaeb2ca84414d6e1367;p=external%2Fglibc.git * resolv/res_hconf.c (_res_hconf_reorder_addrs): Use a union to copy data from cur_ifr->ifr_addr and cur_ifr->ifr_netmask. --- diff --git a/ChangeLog b/ChangeLog index 77429f7..f2d0cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-06-01 Steve Ellcey + + * resolv/res_hconf.c (_res_hconf_reorder_addrs): Use a union to + copy data from cur_ifr->ifr_addr and cur_ifr->ifr_netmask. + 2015-05-29 Adhemerval Zanella * sysdeps/powerpc/fpu/libm-test-ulps: Update. diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c index 73942e8..b9c229d 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;