From owner-freebsd-bugs Sat Nov 18 02:42:32 1995 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA12470 for bugs-outgoing; Sat, 18 Nov 1995 02:42:32 -0800 Received: from marimo.cs.titech.ac.jp (marimo.cs.titech.ac.jp [131.112.80.6]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id CAA12453 for ; Sat, 18 Nov 1995 02:42:13 -0800 Received: by marimo.cs.titech.ac.jp (8.6.12+2.4W/3.2W-titmx-2.0g); Sat, 18 Nov 1995 19:41:59 +0900 Message-Id: <199511181041.TAA16351@marimo.cs.titech.ac.jp> To: freebsd-bugs@freebsd.org Cc: kouji@cs.titech.ac.jp Subject: _gethostbynisaddr() Reply-To: kouji@cs.titech.ac.jp X-Mailer: Mew beta version 0.99+ on Emacs 19.28.10, Mule 2.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Date: Sat, 18 Nov 1995 19:41:59 +0900 From: YAMAMOTO Kouji Sender: owner-bugs@freebsd.org Precedence: bulk I think there is a bug at _gethostbynisaddr() in lib/libc/net/gethostbynis.c still in 2.1.0-RELEASE. Here is my patch. --- gethostbynis.c.org Sun Sep 25 11:12:14 1994 +++ gethostbynis.c Sat Nov 18 18:55:00 1995 @@ -111,5 +111,12 @@ _gethostbynisaddr(name) char *name; { - return _gethostbynis(name, "hosts.byaddr"); + char addr[16]; + + sprintf(addr, "%d.%d.%d.%d", + (unsigned char)(name[0]), + (unsigned char)(name[1]), + (unsigned char)(name[2]), + (unsigned char)(name[3])); + return _gethostbynis(addr, "hosts.byaddr"); } This function is called from gethostbyaddr() in lib/libc/net/gethostnamadr.c, with 3 parameters. But _gethostbynisaddr() accepts only one parameter. ( But this causes no problems.) In addition, the first parameter is brought from __ivaliduser() in lib/libc/net/rcmd.c. In _gethostbynisaddr() (and _gethostbynis() ), the contents of the paramater is treated as a pointer to a char-string though the contents __ivaliduser() sends as a parameter is the pointer to u_long! So the validation by __invaliduser() will sometimes fail. ( This is taken place only when host address is checked by NIS.) Thank you. ---- YAMAMOTO Kouji < kouji@cs.titech.ac.jp > Grad. School of Info.Sci. & Eng., Dept. of Comp.Sci. Tokyo Institute of Technology