diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-05-27 08:17:05 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-05-27 08:17:05 +0000 |
commit | b455972fdaf438fec1ee1467fee5d29ee5569333 (patch) | |
tree | ffd9da46c9e37ffb1e14d7abd81b82854b4e11f3 /nss | |
parent | 9c42c64d305549cc74dd10739d1fc5de813abe31 (diff) | |
download | glibc-b455972fdaf438fec1ee1467fee5d29ee5569333.tar.gz glibc-b455972fdaf438fec1ee1467fee5d29ee5569333.tar.xz glibc-b455972fdaf438fec1ee1467fee5d29ee5569333.zip |
Update.
2000-05-27 Ulrich Drepper <drepper@redhat.com> * sysdeps/posix/getaddrinfo.c (gaih_inet): If req->ai_family == AF_UNSPEC don't allow the IPv6 lookup to return mapped IPv4 addresses. * nss/nss_files/files-hosts.c (LINE_PARSER): Simplify. Correct handling of AI_V4MAPPED flag. * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): If lookup of IPv6 address failed and RES_USE_INET6 bit in _res.options is set, perform lookup for T_A type and tell getanswer_r to convert the result with new argument. (_nss_dns_gethostbyaddr_r): Pass zero as new argument to getanswer_r. Don't convert addresses from IPv4 to IPv6 here. (getanswer_r): Take new parameter indicating if mapping from IPv4 to IPv6 is wanted. Allow qtype and type from reply to disagree if IPv4 mapping has to be done. Perform mappings if required by the caller and not if RES_USE_INET6 bit in _res.options is set. Add several __builtin_expect.
Diffstat (limited to 'nss')
-rw-r--r-- | nss/nss_files/files-hosts.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c index 6f9f68c685..e73fee0b14 100644 --- a/nss/nss_files/files-hosts.c +++ b/nss/nss_files/files-hosts.c @@ -53,31 +53,19 @@ LINE_PARSER STRING_FIELD (addr, isspace, 1); /* Parse address. */ - if (af == AF_INET && inet_pton (AF_INET, addr, entdata->host_addr) > 0) - { - if (flags & AI_V4MAPPED) - { - map_v4v6_address ((char *) entdata->host_addr, - (char *) entdata->host_addr); - result->h_addrtype = AF_INET6; - result->h_length = IN6ADDRSZ; - } - else - { - result->h_addrtype = AF_INET; - result->h_length = INADDRSZ; - } - } - else if (af == AF_INET6 - && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) - { - result->h_addrtype = AF_INET6; - result->h_length = IN6ADDRSZ; - } - else + if (inet_pton (af, addr, entdata->host_addr) <= 0 + && (af != AF_INET6 || (flags & AI_V4MAPPED) == 0 + || inet_pton (AF_INET, addr, entdata->host_addr) <= 0 + || (map_v4v6_address ((char *) entdata->host_addr, + (char *) entdata->host_addr), + 0))) /* Illegal address: ignore line. */ return 0; + /* We always return entries of the requested form. */ + result->h_addrtype = af; + result->h_length = af == AF_INET ? INADDRSZ : IN6ADDRSZ; + /* Store a pointer to the address in the expected form. */ entdata->h_addr_ptrs[0] = entdata->host_addr; entdata->h_addr_ptrs[1] = NULL; @@ -97,6 +85,8 @@ DB_LOOKUP (hostbyname, ,, }, const char *name) #undef EXTRA_ARGS_VALUE +/* XXX Is using _res to determine whether we want to convert IPv4 addresses + to IPv6 addresses really the right thing to do? */ #define EXTRA_ARGS_VALUE \ , af, ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0) DB_LOOKUP (hostbyname2, ,, |