Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jan 2002 00:06:36 +0100 (CET)
From:      Serge van den Boom <svdb@stack.nl>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   misc/34390: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
Message-ID:  <20020128230636.775A7969B@toad.stack.nl>

next in thread | raw e-mail | index | archive | help

>Number:         34390
>Category:       misc
>Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 28 15:10:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Serge van den Boom
>Release:        FreeBSD 4.5-RC i386
>Organization:
M.C.G.V. Stack
>Environment:
System: FreeBSD toad.stack.nl 4.5-RC FreeBSD 4.5-RC #0: Fri Jan 25 01:23:40 CET 2002 dean@toad.stack.nl:/toad.mnt/sources/4.x/sys/compile/toad_vwww i386

>Description:
When using getaddrinfo with AI_NUMERICHOST set in the options field of
the hints structure, and passing a non-numeric host name, EAI_NODATA is
returned. RFC 2553 requires an error code of EAI_NONAME in that case though,
and this is what the getaddrinfo man page also says (in fact it's the same
text).

>How-To-Repeat:
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>

int
main(int argc, char *argv[]) {
	struct addrinfo ai_hints;
	struct addrinfo *ai_res;
	int ai_retval;

	memset(&ai_hints, 0, sizeof ai_hints);
	ai_hints.ai_family = PF_UNSPEC;
	ai_hints.ai_socktype = SOCK_STREAM;
	ai_hints.ai_protocol = IPPROTO_TCP;
	ai_hints.ai_flags = AI_NUMERICHOST;
	ai_retval = getaddrinfo("host.example.net", "9", &ai_hints, &ai_res);
	printf("getaddrinfo returned %d, should be %d (EAI_NONAME).\n",
			ai_retval, EAI_NONAME);
	(void) argc;
	(void) argv;
	return EXIT_SUCCESS;
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020128230636.775A7969B>