Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Mar 1998 23:10:06 -0800 (PST)
From:      dan@dpcsys.com
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/6121: bug in gethostbyname 2.2.5
Message-ID:  <199803240710.XAA07548@calafia.beach.net>

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

>Number:         6121
>Category:       bin
>Synopsis:       gethostbyname(3) no longer returns NO_DATA for MX records
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 23 23:20:01 PST 1998
>Last-Modified:
>Originator:     Dan Busarow
>Organization:
DPC Systems
>Release:        FreeBSD 2.2.5-RELEASE i386
>Environment:
				NA ?
	

>Description:

	

	gethostbyname is documented to return NO_DATA when given a hostname
	that has no A record but does have some other RR, specifically an
	MX record in my case.  This has been working though I think the
	latest release I know for a fact that it works on is 2.1.5, maybe
	2.2-R.  I'll see if I can bring it any closer to the present.

	The following code demonstrates the problem.

>How-To-Repeat:
	Run with an argument of the host to check, i.e. ./tgethost beach.net
	(which succeeds, beach.net has an A record) or ./tgethost penofin.com
	(which fails, penofin.com only has an MX record.  It should return NO_DATA)


	

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <netdb.h>

extern int h_errno;
char errbuf[200];

main(int argc, char **argv) 
{
	struct hostent *he;
	char host[64];
	long rc = 0;
	int error = 0;
	
	strcpy(host, argv[1]);

	sprintf(errbuf, "%s.", host);
		
	he = gethostbyname(errbuf);
	if(he == (struct hostent *)NULL)
	{
		switch(h_errno)
		{
			case HOST_NOT_FOUND:
				printf("|%s| HOST_NOT_FOUND\n", errbuf);
				error = 1;
				break;
			case NO_RECOVERY:
				printf("|%s| NO_RECOVERY\n", errbuf);
				error = 1;
				break;
			case TRY_AGAIN:
				printf("|%s| TRY_AGAIN\n", errbuf);
				error = 1;
				break;
			case NO_DATA:
				printf("|%s| NO_DATA\n", errbuf);
				error = 0;
				break;
		}
	}

	printf("%s %s\n", host, error ? "is bad" : "is good");
	if(error)
		printf("error is %s\n", hstrerror(h_errno));
	
	exit(0);
}

>Fix:
	
	

	I'll look when I have time but this *must* have shown up
	elsewhere.  I see a related outstanding PR for gethostbyname
	failing with high file descriptors.

	My FD_SETSIZE is 256 and open_max is 64.

	Dan
>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?199803240710.XAA07548>