summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-31 09:25:47 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-31 09:25:47 +0000
commit7fdd6ebfe6efedc16b35cb42e2c427cbf07530b0 (patch)
treea087c127904f21595cccc3cf25bbad5e97e02ebe
parent070f8244dbf0193ebec12bf53efc81f0b21bfd22 (diff)
do not gethostbyname() of #.#.#.#
-rw-r--r--libexec/rlogind/rlogind.c40
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) {