Package: libc6 Version: 2.24-8 Severity: normal Tags: upstream patch Hello,
for ease of reproducibility I show my examples in Python, but I verified that the problem is in glibc and not in Python: On a machine without network access I get: >>> import socket >>> socket.getaddrinfo("0.0.0.0", "http", family=socket.AF_INET, flags=socket.AI_ADDRCONFIG) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known as expected. If however I use AF_UNSPEC instead of AF_INET I get: >>> socket.getaddrinfo("0.0.0.0", "http", family=socket.AF_UNSPEC, flags=socket.AI_ADDRCONFIG) [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('0.0.0.0', 80))] while it should fail in the same way as above instead. Quoting getaddrinfo(3): If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4 addresses are returned in the list pointed to by res only if the local system has at least one IPv4 address configured [...]. The following patch should fix this: --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -2351,7 +2351,8 @@ } } else if ((hints->ai_family == PF_INET && ! seen_ipv4) - || (hints->ai_family == PF_INET6 && ! seen_ipv6)) + || (hints->ai_family == PF_INET6 && ! seen_ipv6) + || (hints->ai_family == PF_UNSPEC)) { /* We cannot possibly return a valid answer. */ __free_in6ai (in6ai); Best regards Uwe -- System Information: Debian Release: 9.0 APT prefers testing APT policy: (800, 'testing'), (600, 'unstable'), (500, 'testing-debug'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)