diff --git a/src/kits/network/netresolv/irs/getaddrinfo.c b/src/kits/network/netresolv/irs/getaddrinfo.c index b14e3dc5ab..8c901b1e38 100644 --- a/src/kits/network/netresolv/irs/getaddrinfo.c +++ b/src/kits/network/netresolv/irs/getaddrinfo.c @@ -594,11 +594,22 @@ 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) - 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 */ @@ -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; }