diff options
author | Yang Tse <yangsita@gmail.com> | 2010-11-12 18:53:58 +0100 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-11-12 18:53:58 +0100 |
commit | 747981be8eadc4d8be5bc673c0b64efa556adf4e (patch) | |
tree | a3840a9d71ba5f183ee8a505ff6b15c40594c91f /ares_process.c | |
parent | b8044334f01a25ce74674ccdc041dddee8d3bc4b (diff) | |
download | c-ares-747981be8eadc4d8be5bc673c0b64efa556adf4e.tar.gz c-ares-747981be8eadc4d8be5bc673c0b64efa556adf4e.tar.bz2 c-ares-747981be8eadc4d8be5bc673c0b64efa556adf4e.zip |
Revert following commits:
07bc7ea79509bcc9ef6e09151e81766ed00d3392
3392a50ea3f8573ea4b7a9d82b9833dab60cb0e9
9912637d32c9987719a1ea12db591aee2941891c
The purpose of the whole patch was to silence a compiler warning triggered
with GCC 4 on file ares_process.c The specific compiler warning was
'dereferencing type-punned pointer might break strict-aliasing rules'.
A simpler patch will follow to equally silence the warning.
Diffstat (limited to 'ares_process.c')
-rw-r--r-- | ares_process.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/ares_process.c b/ares_process.c index 8e9a9cd..c3d7fa4 100644 --- a/ares_process.c +++ b/ares_process.c @@ -434,15 +434,11 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, unsigned char buf[PACKETSZ + 1]; #ifdef HAVE_RECVFROM ares_socklen_t fromlen; -#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SSFAM - struct sockaddr_storage from; -#else union { struct sockaddr_in sa4; struct sockaddr_in6 sa6; } from; #endif -#endif if(!read_fds && (read_fd == ARES_SOCKET_BAD)) /* no possible action */ @@ -477,7 +473,10 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, * packets as we can. */ do { #ifdef HAVE_RECVFROM - fromlen = sizeof(from); /* doesn't matter if it's larger than needed */ + if (server->addr.family == AF_INET) + fromlen = sizeof(from.sa4); + else + fromlen = sizeof(from.sa6); count = (ssize_t)recvfrom(server->udp_socket, (void *)buf, sizeof(buf), 0, (struct sockaddr *)&from, &fromlen); #else @@ -488,15 +487,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, else if (count <= 0) handle_error(channel, i, now); #ifdef HAVE_RECVFROM -#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SSFAM - /* This family hack works around compiler warnings about - * aliases. - */ - else if (!((from.ss_family == server->addr.family) && - same_address((struct sockaddr *)&from, &server->addr))) -#else else if (!same_address((struct sockaddr *)&from, &server->addr)) -#endif /* The address the response comes from does not match * the address we sent the request to. Someone may be * attempting to perform a cache poisoning attack. */ @@ -1186,10 +1177,8 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa) void *addr1; void *addr2; -#ifndef HAVE_STRUCT_SOCKADDR_STORAGE_SSFAM if (sa->sa_family == aa->family) { -#endif switch (aa->family) { case AF_INET: @@ -1207,9 +1196,7 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa) default: break; } -#ifndef HAVE_STRUCT_SOCKADDR_STORAGE_SSFAM } -#endif return 0; /* different */ } |