Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Nov 1995 19:41:59 +0900
From:      YAMAMOTO Kouji <kouji@cs.titech.ac.jp>
To:        freebsd-bugs@freebsd.org
Cc:        kouji@cs.titech.ac.jp
Subject:   _gethostbynisaddr()
Message-ID:  <199511181041.TAA16351@marimo.cs.titech.ac.jp>

next in thread | raw e-mail | index | archive | help
 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



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