Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jul 1995 02:40:02 -0700
From:      greg@greg.rim.or.jp
To:        freebsd-bugs
Subject:   misc/605: 
Message-ID:  <199507090940.CAA25136@freefall.cdrom.com>
In-Reply-To: Your message of Sun, 9 Jul 1995 16:26:58 %2B0900 <199507090726.QAA07015@apollon.greg.rim.or.jp>

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

>Number:         605
>Category:       misc
>Synopsis:       
>Confidential:   yes
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul  9 02:40:02 1995
>Originator:     Kensaku Masuda
>Organization:
// 増田  健作 greg@greg.rim.or.jp                  ////
    //             greg@apt.fxis.fujixerox.co.jp         //
   //  大バグは歩いて来ない、だから潰しに行くんだね!   //
  //// 一日一個、三日で三個、三個潰して二個バグる      //
>Release:        FreeBSD 2.0.5-RELEASE i386
>Environment:

	    At using NIS without DNS, /etc/hosts and/or /etc/networks
	has no entries without myself. But NIS map have them.

	ex)
		/etc/hosts
			127.0.0.1	localhost
			WWW.XXX.YYY.ZZ0	myname.mydomain myname

		/etc/networks
			loopback	127
			localnet	WWW.XXX.YYY

		hosts.byaddr
			127.0.0.1		localhost
			WWW.XXX.YYY.ZZ0		myname.mydomain	myname
			WWW.XXX,YYY.ZZ1		friend.mydomain	friend

		networks.byaddr
			mydomain	WWW.XXX.YYY
			loopback	127
			multicast	224

>Description:

	    Building a query problem with NIS in standard C library.

>How-To-Repeat:

	    Use NIS without DNS. and query not in the /etc/hosts.
	for example "netstat -r" / "ping unknwon.host.in.hosts" etc etc.......

>Fix:
	
diff -rc net.original/gethostbynis.c net/gethostbynis.c
*** net.original/gethostbynis.c	Sun Jul  9 15:41:15 1995
--- net/gethostbynis.c	Sun Jul  9 14:59:47 1995
***************
*** 111,115 ****
  _gethostbynisaddr(name)
  	char *name;
  {
! 	return _gethostbynis(name, "hosts.byaddr");
  }
--- 111,120 ----
  _gethostbynisaddr(name)
  	char *name;
  {
! 	static char buffer[64];
! 	unsigned char *tmp;
! 
! 	tmp = (unsigned char *)name;
! 	sprintf(buffer, "%u.%u.%u.%u", tmp[0], tmp[1], tmp[2], tmp[3]);
! 	return _gethostbynis(buffer, "hosts.byaddr");
  }
Only in net: gethostbynis.c.original
diff -rc net.original/getnetbynis.c net/getnetbynis.c
*** net.original/getnetbynis.c	Sun Jul  9 15:41:15 1995
--- net/getnetbynis.c	Sun Jul  9 15:32:26 1995
***************
*** 118,133 ****
  	struct in_addr in;
  	char *str, *cp;
  	struct netent *np;
  
  	if (type != AF_INET)
  		return (NULL);
  
! 	in.s_addr = addr;
  	str = inet_ntoa(in);
! 	cp = str + strlen(str) - 2;
! 	while(!strcmp(cp, ".0")) {
! 		*cp = '\0';
! 		cp = str + strlen(str) - 2;
  	}
  
  	return _getnetbynis(str, "networks.byaddr");
--- 118,148 ----
  	struct in_addr in;
  	char *str, *cp;
  	struct netent *np;
+ 	unsigned char name[4];
+ 	unsigned char tmp[4];
  
  	if (type != AF_INET)
  		return (NULL);
  
! 	/*
! 	 * It's a quick hack, please rewrite into a beautifully.
! 	 * By Kensaku Masuda <greg@greg.rim.or.jp> 1995/07/09
! 	 */
! 	memcpy(tmp, &addr, sizeof(tmp));
! 	name[3] = tmp[2];
! 	name[2] = tmp[1];
! 	name[1] = tmp[0];
! 	name[0] = tmp[3];
! 	in.s_addr = name[0] << 24 | name[1] << 16 | name[2] << 8 | name[3];
  	str = inet_ntoa(in);
! 	for(cp = str + strlen(str) ; str != cp ; cp--) {
! 		if(*cp == '.') {
! 			if(strcmp(cp, ".0") == 0) {
! 				*cp = 0;
! 			} else {
! 				break;
! 			}
! 		}
  	}
  
  	return _getnetbynis(str, "networks.byaddr");

>Audit-Trail:
>Unformatted:





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