diff options
author | 1996-07-31 09:25:46 +0000 | |
---|---|---|
committer | 1996-07-31 09:25:46 +0000 | |
commit | dbe2040b56437492952202800756008e5a33529b (patch) | |
tree | 3fcc807bd0354300e191cd0fbaaa00919e96bbb6 | |
parent | ah heck, impliment -a flag and turn it on by default. kills netbsd pr#1295 (diff) | |
download | wireguard-openbsd-dbe2040b56437492952202800756008e5a33529b.tar.xz wireguard-openbsd-dbe2040b56437492952202800756008e5a33529b.zip |
do not gethostbyname() of #.#.#.#
-rw-r--r-- | libexec/rlogind/rlogind.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index cc89ab8d087..77043204c91 100644 --- a/libexec/rlogind/rlogind.c +++ b/libexec/rlogind/rlogind.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: rlogind.c,v 1.6 1996/07/31 09:15:53 deraadt Exp $"; +static char *rcsid = "$Id: rlogind.c,v 1.7 1996/07/31 09:25:46 deraadt Exp $"; #endif /* not lint */ /* @@ -198,6 +198,7 @@ doit(f, fromp) int authenticated = 0; register struct hostent *hp; char hostname[MAXHOSTNAMELEN]; + int good = 0; char c; alarm(60); @@ -214,29 +215,26 @@ doit(f, fromp) fromp->sin_port = ntohs((u_short)fromp->sin_port); hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr), fromp->sin_family); - if (hp) + if (hp) { strncpy(hostname, hp->h_name, sizeof hostname); - else + if (check_all) { + hp = gethostbyname(hostname); + if (hp) { + for (; good == 0 && hp->h_addr_list[0] != NULL; + hp->h_addr_list++) + if (!bcmp(hp->h_addr_list[0], + (caddr_t)&fromp->sin_addr, + sizeof(fromp->sin_addr))) + good = 1; + } + + } else + good = 1; + } + /* aha, the DNS looks spoofed */ + if (hp == NULL || good == 0) strncpy(hostname, inet_ntoa(fromp->sin_addr), sizeof hostname); - if (check_all) { - int good = 0; - - hp = gethostbyname(hostname); - if (hp) { - for (; good == 0 && hp->h_addr_list[0] != NULL; - hp->h_addr_list++) - if (!bcmp(hp->h_addr_list[0], - (caddr_t)&fromp->sin_addr, - sizeof(fromp->sin_addr))) - good = 1; - } - - /* aha, the DNS looks spoofed */ - if (hp == NULL || good == 0) - strncpy(hostname, inet_ntoa(fromp->sin_addr), - sizeof hostname); - } #ifdef KERBEROS if (use_kerberos) { |