[Bug 198092] getaddrinfo(3) fails with "Invalid value for ai_flags" (error code 3) if hint.ai_flags contains AI_V4MAPPED

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Feb 28 14:30:40 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092

            Bug ID: 198092
           Summary: getaddrinfo(3) fails with "Invalid value for ai_flags"
                    (error code 3) if hint.ai_flags contains AI_V4MAPPED
           Product: Base System
           Version: 10.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: standards
          Assignee: freebsd-standards at FreeBSD.org
          Reporter: andriys at gmail.com

The getaddrinfo(3) manual page refer to POSIX.1 and RFC 3493 in the STANDARDS
section. Both of these documents say getaddrinfo accepts AI_V4MAPPED flag in
the hint. In fact if the AI_V4MAPPED bit is set in the ai_flags member of the
hint addrinfo structure, getaddrinfo(3) always fails with error code 3
("Invalid value for ai_flags").

This can be easily demonstrated with the following sample code:

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>

int main(void)
{
    struct addrinfo *ai;
    struct addrinfo hint;
    int errcode;

    memset(&hint, 0, sizeof(hint));
    hint.ai_family = PF_INET6;
    hint.ai_flags = AI_V4MAPPED;

    errcode = getaddrinfo("freebsd.org", "80", &hint, &ai);
    if(errcode) {
        fprintf(stderr, "Error %d: %s\n", errcode, gai_strerror(errcode));
        return 1;
    }

    freeaddrinfo(ai);
    return 0;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-standards mailing list