From greg@greg.rim.or.jp  Fri Mar 15 08:30:05 1996
Received: from rayearth.rim.or.jp (uucp@rayearth.rim.or.jp [202.247.130.242])
          by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id IAA08488
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Mar 1996 08:30:03 -0800 (PST)
Received: (from uucp@localhost) by rayearth.rim.or.jp (8.7.5/3.4W3-uucp1) with UUCP
	id BAA07525 for FreeBSD-gnats-submit@freebsd.org; Sat, 16 Mar 1996 01:29:53 +0900 (JST)
Received: from apollon.greg.rim.or.jp (apollon.greg.rim.or.jp [172.31.1.2]) by atena.greg.rim.or.jp (8.6.12/3.4Wbeta6) with ESMTP id BAA22149 for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Mar 1996 01:22:25 +0900
Received: by apollon.greg.rim.or.jp (8.7.4/3.3Wb-uucp-sendmail-slave-Ver-0.1-Beta)
	id BAA26562; Sat, 16 Mar 1996 01:22:24 +0900 (JST)
Message-Id: <199603151622.BAA26562@apollon.greg.rim.or.jp>
Date: Sat, 16 Mar 1996 01:22:24 +0900 (JST)
From: greg@greg.rim.or.jp
Reply-To: greg@greg.rim.or.jp
To: FreeBSD-gnats-submit@freebsd.org
Subject: Can not work about get{host|net]byaddr on NIS.
X-Send-Pr-Version: 3.2

>Number:         1079
>Category:       misc
>Synopsis:       Can not work about get{host|net]byaddr on NIS.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    wpaul
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 15 08:40:02 PST 1996
>Closed-Date:    Mon Oct 21 21:06:11 PDT 1996
>Last-Modified:  Tue Nov 27 18:52:50 PST 2001
>Originator:     Kensaku Masuda
>Release:        FreeBSD 2.2-960303-SNAP i386
>Organization:
Private domain
>Environment:

	My /etc/host.conf is

	# bind
	# If that doesn't work, then try the /etc/hosts file
	hosts
	# If you have YP/NIS configured, uncomment the next line
	nis

>Description:

	I have two problems. and one of them is fixed, But left is not fixed.
	At first, If I selected NIS about host/net resolving, can not find 
symbol name from IP address.

Ex)

# netstat -r
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use     Netif Expire
127.0.0.1          127.0.0.1          UH          0        0       lo0
123.456.789/24     link#2             UC          0        0
MyName             0:0:1:6:39:68      UHLW       11   114467       ep0    278
123.456.789.1      0:20:af:26:a0:87   UHLW        8    95529       lo0
123.456.789.255    link#2             UHLW        1      527

	At last, "exit" function in Standard C library has one problem.
If some program is using STREAM functions. it will catch a signal at calling
"exit" ( BUS ERROR ). But all program is not recving a signal. May be, only
using "get{net/host]byaddr".

>How-To-Repeat:

	1st problem : Use NIS and call get{host/net]byaddr.
	2nd problem : run " netstat "

>Fix:
	This patch is fixed 1st problem.

diff -ruN net.original/gethostbynis.c net/gethostbynis.c
--- net.original/gethostbynis.c	Sat Mar 16 00:30:59 1996
+++ net/gethostbynis.c	Sat Mar 16 00:26:23 1996
@@ -111,5 +111,10 @@
 _gethostbynisaddr(name)
 	char *name;
 {
-	return _gethostbynis(name, "hosts.byaddr");
+	struct in_addr in;
+	/*
+	 * Fast Hack
+	 */
+	in.s_addr = *((long *)name);
+	return _gethostbynis(inet_ntoa(in), "hosts.byaddr");
 }
diff -ruN net.original/getnetbynis.c net/getnetbynis.c
--- net.original/getnetbynis.c	Sat Mar 16 00:30:56 1996
+++ net/getnetbynis.c	Sat Mar 16 00:28:18 1996
@@ -122,8 +122,20 @@
 	if (type != AF_INET)
 		return (NULL);
 
-	in.s_addr = addr;
+	/*
+	 * The input is host byte oder, But inet_ntoa request network byte oder
+	 */
+	in.s_addr = htonl(addr);
 	str = inet_ntoa(in);
+	/*
+	 * Must checking. if inet_ntoa return NULL string, Will core dumped
+	 */
+	if(str == NULL) {
+		return NULL;
+	}
+	if(strlen(str) < 2) {
+		return NULL;
+	}
 	cp = str + strlen(str) - 2;
 	while(!strcmp(cp, ".0")) {
 		*cp = '\0';

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->wpaul 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Tue Sep 24 17:16:23 PDT 1996 
Responsible-Changed-Why:  
Mr. NIS 
State-Changed-From-To: open->closed 
State-Changed-By: wpaul 
State-Changed-When: Mon Oct 21 21:06:11 PDT 1996 
State-Changed-Why:  

This was fixed in both -stable and -current before FreeBSD 2.1.5 
was released. 
>Unformatted:
