X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/e14d27a1c47025c81e1fc62a51b0c355ec7f4957..e693a2d9c8385b9177a24e28ab63701973975919:/unix/uxnet.c diff --git a/unix/uxnet.c b/unix/uxnet.c index 5cf70082..d51d75f0 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -145,14 +145,16 @@ SockAddr sk_namelookup(const char *host, char **canonicalname, int address_famil #ifndef NO_IPV6 hints.ai_flags = AI_CANONNAME; - hints.ai_family = address_family; - hints.ai_socktype = 0; + hints.ai_family = (address_family == ADDRTYPE_IPV4 ? AF_INET : + address_family == ADDRTYPE_IPV6 ? AF_INET6 : + AF_UNSPEC); + hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; hints.ai_addrlen = 0; hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; - err = getaddrinfo(host, NULL, NULL, &ret->ai); + err = getaddrinfo(host, NULL, &hints, &ret->ai); if (err != 0) { ret->error = gai_strerror(err); return ret;