diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-02-09 11:33:36 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-02-09 11:33:36 +0200 |
commit | a7512f3eb03ae2b6361e56518a2f405e386315a0 (patch) | |
tree | 141e85f9b2fee728883e3851628da02f72ef639c /io.c | |
parent | 4f92f35791d975671881e21f6b79b71050fd2787 (diff) | |
parent | c1e55fde1a4bb72a0627ab37fe5ba1493cbf91eb (diff) | |
download | egawk-a7512f3eb03ae2b6361e56518a2f405e386315a0.tar.gz egawk-a7512f3eb03ae2b6361e56518a2f405e386315a0.tar.bz2 egawk-a7512f3eb03ae2b6361e56518a2f405e386315a0.zip |
Merge branch 'gawk-4.2-stable'
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1579,10 +1579,23 @@ socketopen(int family, int type, const char *localpname, int any_remote_host = (strcmp(remotehostname, "0") == 0); memset(& lhints, '\0', sizeof (lhints)); - lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + lhints.ai_socktype = type; lhints.ai_family = family; + /* + * If only the loopback interface is up and hints.ai_flags has + * AI_ADDRCONFIG, getaddrinfo() will succeed and return all wildcard + * addresses, but only if hints.ai_family == AF_UNSPEC + * + * Do return the wildcard address in case the loopback interface + * is the only one that is up (and + * hints.ai_family == either AF_INET4 or AF_INET6) + */ + lhints.ai_flags = AI_PASSIVE; + if (lhints.ai_family == AF_UNSPEC) + lhints.ai_flags |= AI_ADDRCONFIG; + lerror = getaddrinfo(NULL, localpname, & lhints, & lres); if (lerror) { if (strcmp(localpname, "0") != 0) { |