aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-05-27 08:09:40 +0000
committerUlrich Drepper <drepper@redhat.com>2000-05-27 08:09:40 +0000
commit9c42c64d305549cc74dd10739d1fc5de813abe31 (patch)
tree6276ba2d6d68443ef61a699d5fc5fc56c1d11c22 /sysdeps/posix
parentaac468aee2f3e8c5a1b2a9ee54b2926a8a1aa203 (diff)
downloadglibc-9c42c64d305549cc74dd10739d1fc5de813abe31.tar
glibc-9c42c64d305549cc74dd10739d1fc5de813abe31.tar.gz
glibc-9c42c64d305549cc74dd10739d1fc5de813abe31.tar.bz2
glibc-9c42c64d305549cc74dd10739d1fc5de813abe31.zip
(gaih_inet): If req->ai_family == AF_UNSPEC don't allow the IPv6 lookup to return mapped IPv4 addresses.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getaddrinfo.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 59e2cec129..45d1da22f9 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assert.h>
#include <errno.h>
#include <netdb.h>
+#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -430,11 +431,22 @@ gaih_inet (const char *name, const struct gaih_service *service,
struct gaih_addrtuple **pat = &at;
int no_data = 0;
int no_inet6_data;
+ int old_res_options = _res.options;
+
+ /* If we are looking for both IPv4 and IPv6 address we don't
+ want the lookup functions to automatically promote IPv4
+ addresses to IPv6 addresses. Currently this is decided
+ by setting the RES_USE_INET6 bit in _res.options. */
+ if (req->ai_family == AF_UNSPEC)
+ _res.options &= ~RES_USE_INET6;
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
gethosts (AF_INET6, struct in6_addr);
no_inet6_data = no_data;
+ if (req->ai_family == AF_UNSPEC)
+ _res.options = old_res_options;
+
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
gethosts (AF_INET, struct in_addr);