getaddrinfo: properly implement AI_ADDRCONFIG
* Exclude the localhost interface when building the supported family list, * Filter DNS replies to keep only the allowed address families. Fixes #8293, for real this time.
This commit is contained in:
committed by
Adrien Destugues
parent
2bf1d39d9d
commit
c1dbcef20d
@@ -594,12 +594,23 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||
if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
|
||||
pai->ai_protocol = ex->e_protocol;
|
||||
|
||||
/* append entries to list of replies */
|
||||
error = explore_fqdn(pai, hostname, servname, &cur->ai_next,
|
||||
&svd);
|
||||
|
||||
while (cur && cur->ai_next)
|
||||
while (cur && cur->ai_next) {
|
||||
if ((((uint64_t)1 << cur->ai_next->ai_family) & mask) == 0) {
|
||||
/* entry does not match addrconfig mask, remove from list */
|
||||
struct addrinfo* removed = cur->ai_next;
|
||||
cur->ai_next = removed->ai_next;
|
||||
removed->ai_next = NULL;
|
||||
freeaddrinfo(removed);
|
||||
} else {
|
||||
/* entry does match, keep it in list and move to next one */
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
if (sentinel.ai_next)
|
||||
@@ -1094,7 +1105,8 @@ addrconfig(uint64_t *mask)
|
||||
|
||||
*mask = 0;
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next)
|
||||
if (ifa->ifa_addr && (ifa->ifa_flags & IFF_UP)) {
|
||||
if (ifa->ifa_addr && (ifa->ifa_flags & IFF_UP)
|
||||
&& !(ifa->ifa_flags & IFF_LOOPBACK)) {
|
||||
assert(ifa->ifa_addr->sa_family < 64);
|
||||
*mask |= (uint64_t)1 << ifa->ifa_addr->sa_family;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user