Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 19 Jul 2021 15:58:25 +0300
From: Yuri Kanivetsky <yuri.kanivetsky@...il.com>
To: musl@...ts.openwall.com
Subject: getaddrinfo() fails for domains with no AAAA records (regression?)

Hi,

a.c:

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

    int
    main(int argc, char *argv[])
    {
        struct addrinfo hints;
        struct addrinfo *result, *rp;
        int r;
        char s[INET6_ADDRSTRLEN];

        memset(&hints, 0, sizeof(hints));
        if (argc > 2)
            hints.ai_family = AF_INET;
        hints.ai_socktype = SOCK_DGRAM;

        r = getaddrinfo(argv[1], NULL, &hints, &result);
        if (r != 0) {
            fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(r));
            exit(EXIT_FAILURE);
        }

        for (rp = result; rp != NULL; rp = rp->ai_next) {
            switch (rp->ai_family) {
            case AF_INET:
                inet_ntop(AF_INET, &((struct sockaddr_in
*)rp->ai_addr)->sin_addr, s, INET6_ADDRSTRLEN);
                printf("AF_INET: %s\n", s);
                break;
            case AF_INET6:
                inet_ntop(AF_INET6, &((struct sockaddr_in6
*)rp->ai_addr)->sin6_addr, s, INET6_ADDRSTRLEN);
                printf("AF_INET6: %s\n", s);
                break;
            }
        }

        freeaddrinfo(result);
    }

a.sh:

    #!/bin/sh -eux
    apk add build-base
    cd app
    gcc a.c
    ./a.out p2.x-yuri.site set_ai_family
    ./a.out p2.x-yuri.site

$ docker run --rm -itv $PWD:/app alpine:3.12 ./app/a.sh
...
+ ./a.out p2.x-yuri.site set_ai_family
AF_INET: 3.67.126.242
+ ./a.out p2.x-yuri.site
AF_INET: 3.67.126.242

$ docker run --rm -itv $PWD:/app alpine:3.13 ./app/a.sh
...
+ ./a.out p2.x-yuri.site set_ai_family
AF_INET: 3.67.126.242
+ ./a.out p2.x-yuri.site
getaddrinfo: Name does not resolve

$ docker run --rm -itv $PWD:/app alpine:3.14 ./app/a.sh
...
+ ./a.out p2.x-yuri.site set_ai_family
AF_INET: 3.67.126.242
+ ./a.out p2.x-yuri.site
getaddrinfo: Name does not resolve

Regards,
Yuri

Download attachment "p1.png" of type "image/png" (79835 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.