From svdb@stack.nl  Mon Jan 28 15:06:39 2002
Return-Path: <svdb@stack.nl>
Received: from skynet.stack.nl (insgate.stack.nl [131.155.140.2])
	by hub.freebsd.org (Postfix) with ESMTP id 1986337B400
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Jan 2002 15:06:38 -0800 (PST)
Received: from toad.stack.nl (toad.stack.nl [2001:610:1108:5010:202:b3ff:fe17:9e1a])
	by skynet.stack.nl (Postfix) with ESMTP id A92CC9B15
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 Jan 2002 00:06:36 +0100 (CET)
Received: by toad.stack.nl (Postfix, from userid 1106)
	id 775A7969B; Tue, 29 Jan 2002 00:06:36 +0100 (CET)
Message-Id: <20020128230636.775A7969B@toad.stack.nl>
Date: Tue, 29 Jan 2002 00:06:36 +0100 (CET)
From: Serge van den Boom <svdb@stack.nl>
Reply-To: Serge van den Boom <svdb@stack.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         34390
>Category:       misc
>Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    roam
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 28 15:10:01 PST 2002
>Closed-Date:    Sun Mar 3 10:45:47 PST 2002
>Last-Modified:  Sun Mar 03 10:46:05 PST 2002
>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:

From: Peter Pentchev <roam@ringlet.net>
To: Serge van den Boom <svdb@stack.nl>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: misc/34390: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
Date: Wed, 30 Jan 2002 13:19:35 +0200

 On Tue, Jan 29, 2002 at 12:06:36AM +0100, Serge van den Boom wrote:
 > 
 > >Number:         34390
 > >Category:       misc
 > >Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
 > >Originator:     Serge van den Boom
 > >Release:        FreeBSD 4.5-RC 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).
 
 Can you try the following patch?  It seems to fix the problem for me.
 It is made against RELENG_4 sources, but applies cleanly to -CURRENT, too.
 
 G'luck,
 Peter
 
 -- 
 What would this sentence be like if pi were 3?
 
 Index: src/lib/libc/net/getaddrinfo.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libc/net/getaddrinfo.c,v
 retrieving revision 1.9.2.8
 diff -u -r1.9.2.8 getaddrinfo.c
 --- src/lib/libc/net/getaddrinfo.c	15 Jun 2001 22:08:28 -0000	1.9.2.8
 +++ src/lib/libc/net/getaddrinfo.c	30 Jan 2002 10:50:07 -0000
 @@ -529,7 +529,7 @@
  		goto good;
  
  	if (pai->ai_flags & AI_NUMERICHOST)
 -		ERR(EAI_NODATA);
 +		ERR(EAI_NONAME);
  	if (hostname == NULL)
  		ERR(EAI_NODATA);
  
State-Changed-From-To: open->feedback 
State-Changed-By: sheldonh 
State-Changed-When: Wed Jan 30 04:35:18 PST 2002 
State-Changed-Why:  
Waiting for originator to try Peter's patch, although it looks 
like an obvious winner. 

Please copy your feedback to <bug-followup@freebsd.org>, using the 
subject line of this message. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=34390 

From: Serge van den Boom <svdb@stack.nl>
To: Peter Pentchev <roam@ringlet.net>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: misc/34390: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
Date: Wed, 30 Jan 2002 17:52:11 +0100 (CET)

 On Wed, 30 Jan 2002, Peter Pentchev wrote:
 > On Tue, Jan 29, 2002 at 12:06:36AM +0100, Serge van den Boom wrote:
 > > >Number:         34390
 > > >Category:       misc
 > > >Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
 > > >Originator:     Serge van den Boom
 > > >Release:        FreeBSD 4.5-RC 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).
 > Can you try the following patch?  It seems to fix the problem for me.
 > It is made against RELENG_4 sources, but applies cleanly to -CURRENT, too.
 Actually, I can't. I don't have root access on the machine I encountered the
 bug on, or any other 4.5-RC machines.
 But I've contacted an administrator and he'll apply the patch later today.
 So I'll get back to you then.
 
 Greetings,
 
 Serge
 
 
 

From: Serge van den Boom <svdb@stack.nl>
To: Peter Pentchev <roam@ringlet.net>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: misc/34390: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
Date: Wed, 30 Jan 2002 19:02:33 +0100 (CET)

 On Wed, 30 Jan 2002, Serge van den Boom wrote:
 > On Wed, 30 Jan 2002, Peter Pentchev wrote:
 > > On Tue, Jan 29, 2002 at 12:06:36AM +0100, Serge van den Boom wrote:
 > > > >Number:         34390
 > > > >Category:       misc
 > > > >Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
 > > > >Originator:     Serge van den Boom
 > > > >Release:        FreeBSD 4.5-RC 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).
 > > Can you try the following patch?  It seems to fix the problem for me.
 > > It is made against RELENG_4 sources, but applies cleanly to -CURRENT, too.
 > Actually, I can't. I don't have root access on the machine I encountered the
 > bug on, or any other 4.5-RC machines.
 > But I've contacted an administrator and he'll apply the patch later today.
 > So I'll get back to you then.
 Verified. It works (no surprise there).
 
 Greetings,
 
 Serge
 
 

From: Peter Pentchev <roam@ringlet.net>
To: Serge van den Boom <svdb@stack.nl>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: misc/34390: incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
Date: Wed, 30 Jan 2002 20:12:53 +0200

 On Wed, Jan 30, 2002 at 05:52:11PM +0100, Serge van den Boom wrote:
 > On Wed, 30 Jan 2002, Peter Pentchev wrote:
 > > On Tue, Jan 29, 2002 at 12:06:36AM +0100, Serge van den Boom wrote:
 > > > >Number:         34390
 > > > >Category:       misc
 > > > >Synopsis:       incorrect error with getaddrinfo with hostname+AI_NUMERICHOST
 > > > >Originator:     Serge van den Boom
 > > > >Release:        FreeBSD 4.5-RC 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).
 > > Can you try the following patch?  It seems to fix the problem for me.
 > > It is made against RELENG_4 sources, but applies cleanly to -CURRENT, too.
 > Actually, I can't. I don't have root access on the machine I encountered the
 > bug on, or any other 4.5-RC machines.
 > But I've contacted an administrator and he'll apply the patch later today.
 > So I'll get back to you then.
 
 You could always try building your own copy of src/lib/libc,
 or just your own copy of src/lib/libc/getaddrinfo.c for that matter :)
 But then, yes, it is almost always easier to do it the standard
 buildworld way.
 
 G'luck,
 Peter
 
 -- 
 What would this sentence be like if pi were 3?
State-Changed-From-To: feedback->analyzed 
State-Changed-By: roam 
State-Changed-When: Wed Jan 30 10:24:52 PST 2002 
State-Changed-Why:  
I am awaiting feedback on this patch as I sent it to -net for review. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=34390 
Responsible-Changed-From-To: freebsd-bugs->roam 
Responsible-Changed-By: roam 
Responsible-Changed-When: Wed Jan 30 11:33:59 PST 2002 
Responsible-Changed-Why:  
Oops, should have changed both State and Responsible in one go. 
I'll take care of this after the audit from -net. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=34390 
State-Changed-From-To: analyzed->suspended 
State-Changed-By: roam 
State-Changed-When: Fri Feb 1 00:35:15 PST 2002 
State-Changed-Why:  
The fix was committed in rev. 1.22 of src/lib/libc/net/getaddrinfo.c. 
It will be merged into -STABLE in a month if no issues come up. 
Thank you for the problem report! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=34390 
State-Changed-From-To: suspended->closed 
State-Changed-By: roam 
State-Changed-When: Sun Mar 3 10:45:47 PST 2002 
State-Changed-Why:  
Fix committed to the RELENG_4 branch. 
Thank you for the problem report! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=34390 
>Unformatted:
