This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug network/21295] New: GETAI(AF_UNSPEC) drops IPv6 addresses if nss module does not support getaddrinfo4_r


https://sourceware.org/bugzilla/show_bug.cgi?id=21295

            Bug ID: 21295
           Summary: GETAI(AF_UNSPEC) drops IPv6 addresses if nss module
                    does not support getaddrinfo4_r
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: network
          Assignee: unassigned at sourceware dot org
          Reporter: glibc at kmeaw dot com
  Target Milestone: ---

GETAI(AF_UNSPEC) only returns the IPv4 result 

CVE-2016-3706 patch introduces a regression which disrupts connectivity
from IPv6-only to dual-stack hosts having an old libnss_dns library.

It affects users of nss modules which does not support new
getaddrinfo4_r interface — glibc falls back to using older
getaddrinfo{2,3}_r interfaces. This bug breaks connectivity
on IPv6-only hosts if you try to connect to a dual-stack
machine — only IPv4 addresses will be provided by getaddrinfo call.

How to reproduce:

Sample program:

#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
        struct addrinfo *result;
        struct addrinfo *res;
        int error;
        char *host = "ya.ru";
        char buf[512];

        /* resolve the domain name into a list of addresses */
        error = getaddrinfo(host, NULL, NULL, &result);
        if (error != 0) {
                if (error == EAI_SYSTEM) {
                        perror("getaddrinfo");
                } else {
                        fprintf(stderr, "error in getaddrinfo: %s\n",
gai_strerror(error));
                }
                exit(EXIT_FAILURE);
        }

        for (res = result; res != NULL; res = res->ai_next) {
                if (res->ai_family == AF_INET)
                        inet_ntop(res->ai_family, &((struct sockaddr_in
*)res->ai_addr)->sin_addr, buf, sizeof(buf));
                else if (res->ai_family == AF_INET6)
                        inet_ntop(res->ai_family, &((struct sockaddr_in6
*)res->ai_addr)->sin6_addr, buf, sizeof(buf));
                else
                        continue;
                puts(buf);
        }

        freeaddrinfo(result);
        return 0;
}

Build and run program:

# gcc foo.c
# ./a.out | sort -u

Actual Result:

213.180.193.3
213.180.204.3
93.158.134.3

Expected Result:

213.180.193.3
213.180.204.3
2a02:6b8::3
93.158.134.3

This is because IPv6 results would get discarded after a successive call
to convert_hostent_to_gaih_addrtuple.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]