From a77173a7cd162a0aa47a96361a70cd43d178b4f6 Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 6 Apr 1999 23:06:00 +0000 Subject: Use realhostname() rather than various combinations of gethostbyaddr() & gethostbyname(). Remove brokeness in ftpd for hosts of MAXHOSTNAMELEN length. --- libexec/rexecd/rexecd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'libexec/rexecd') diff --git a/libexec/rexecd/rexecd.c b/libexec/rexecd/rexecd.c index ac7dca9..740368f 100644 --- a/libexec/rexecd/rexecd.c +++ b/libexec/rexecd/rexecd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)rexecd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: rexecd.c,v 1.15 1997/11/26 07:29:04 charnier Exp $"; #endif /* not lint */ #include @@ -55,6 +55,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -72,7 +73,7 @@ char path[sizeof(_PATH_DEFPATH) + sizeof("PATH=")] = "PATH="; char *envinit[] = {homedir, shell, path, username, 0}; char **environ; -char *remote; +char remote[MAXHOSTNAMELEN + 1]; struct sockaddr_in asin = { AF_INET }; @@ -103,10 +104,7 @@ main(argc, argv) if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) err(1, "getpeername"); - hp = gethostbyaddr((char *) &from.sin_addr, sizeof(from.sin_addr), - from.sin_family); - remote = inet_ntoa(from.sin_addr); - remote = (hp != NULL) ? hp->h_name : inet_ntoa(from.sin_addr); + realhostname(remote, sizeof remote - 1, &from.sin_addr); doit(0, &from); return(0); -- cgit v1.1