From owner-freebsd-bugs Thu Sep 7 8:40: 8 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6A9EC37B43E for ; Thu, 7 Sep 2000 08:40:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id IAA54695; Thu, 7 Sep 2000 08:40:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from h132-197-97-45.gte.com (h132-197-97-45.gte.com [132.197.97.45]) by hub.freebsd.org (Postfix) with ESMTP id EB49F37B443 for ; Thu, 7 Sep 2000 08:39:33 -0700 (PDT) Received: (from ak03@localhost) by h132-197-97-45.gte.com (8.11.0/8.11.0) id e87FdWd07360; Thu, 7 Sep 2000 11:39:32 -0400 (EDT) (envelope-from ak03) Message-Id: <200009071539.e87FdWd07360@h132-197-97-45.gte.com> Date: Thu, 7 Sep 2000 11:39:32 -0400 (EDT) From: ak03@gte.com Reply-To: ak03@gte.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/21092: Resolver errors are not reported properly in NIS-only case Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 21092 >Category: bin >Synopsis: _gethostbynis function does not set h_errno on failure >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 07 08:40:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Alexander Kabaev >Release: FreeBSD 5.0-CURRENT i386 >Organization: Verizon Laboratories Inc. >Environment: FreeBSD kanpc.gte.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Sep 6 12:19:50 EDT 2000 root@kanpc.gte.com:/usr/src/sys/compile/KANPC i386 >Description: If NIS is selected as the only source used for the name resolution in host.conf or in nsswitch.conf on newer -CURRENT and then name resolution attempted for an unknown hostname using gethostbyname* functions, h_error is not getting set correctly when resolution fails. It seems like _gethostbynis function fails to set h_errno variable to the appropriate value when returning. All other functions in the family, i.e. _gethostbydns and _gethostbyht, do so. Without attached patch, the following command returns with strange message: [ak03@kanpc ~]$ ping sjkjss ping: cannot resolve sjkjss: Resolver Error 0 (no error) With patch applied, ping produces more reasonable output: [ak03@kanpc ~]$ ping sjkjss ping: cannot resolve sjkjss: Unknown host >How-To-Repeat: Comment out non-nis entries in host.conf or nsswitch.conf and try to ping some unknown host. Index: gethostbynis.c =================================================================== RCS file: /usr/ncvs/src/lib/libc/net/gethostbynis.c,v retrieving revision 1.10 diff -u -r1.10 gethostbynis.c --- gethostbynis.c 1999/08/28 00:00:06 1.10 +++ gethostbynis.c 2000/09/07 15:12:50 @@ -76,15 +76,20 @@ case AF_INET6: size = NS_IN6ADDRSZ; errno = EAFNOSUPPORT; + h_errno = NETDB_INTERNAL; return NULL; } if (domain == (char *)NULL) - if (yp_get_default_domain (&domain)) + if (yp_get_default_domain (&domain)) { + h_errno = NETDB_INTERNAL; return ((struct hostent *)NULL); + } - if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) + if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) { + h_errno = HOST_NOT_FOUND; return ((struct hostent *)NULL); + } /* avoid potential memory leak */ bcopy((char *)result, (char *)&ypbuf, resultlen); >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message