standards/114910: getaddrinfo() fails to set ai_canonname

Mark Andrews marka at
Wed Jul 25 20:20:02 UTC 2007

>Number:         114910
>Category:       standards
>Synopsis:       getaddrinfo() fails to set ai_canonname
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-standards
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 25 20:20:02 GMT 2007
>Originator:     Mark Andrews
>Release:        FreeBSD 6.2-STABLE i386
System: FreeBSD 6.2-STABLE FreeBSD 6.2-STABLE #16: Fri Apr 27 13:32:57 EST 2007 marka at i386


	getaddrinfo() fails to set ai->ai_canonname when requested.


	Run the following.  It will fail one time in two,  I suspect that
	it is related to the AAAA address and their return order.            167913  IN      A            81490   IN      AAAA    2001:478:6:0:2d0:b7ff:fee8:c4d9            81490   IN      AAAA    3ffe:805::2d0:b7ff:fee8:c4d9

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

main () {
	struct addrinfo hints, *ai = NULL, *cur;
	int result;

        memset(&hints, 0, sizeof(hints));
        hints.ai_flags = AI_CANONNAME;
        hints.ai_family = PF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_protocol = 0;

        result = getaddrinfo("FLAG.EP.NET", NULL, &hints, &ai);
if ((result && ai) || (result == 0 && (ai == NULL || ai->ai_canonname == NULL)))
fprintf(stderr, "getaddrinfo %d %p %p\n", result, ai, ai?ai->ai_canonname:NULL);



More information about the freebsd-standards mailing list