diff options
author | brian <brian@FreeBSD.org> | 1999-04-07 10:17:24 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-04-07 10:17:24 +0000 |
commit | 88f6c1a7e8dcda5f7f3b7b9f5f96554a00d38afc (patch) | |
tree | 90972f181a25ec77bfcbd984847899544b2778fb /crypto | |
parent | 4ef566065e6b94e7776f716eb3b6de7a4fa7e720 (diff) | |
download | FreeBSD-src-88f6c1a7e8dcda5f7f3b7b9f5f96554a00d38afc.zip FreeBSD-src-88f6c1a7e8dcda5f7f3b7b9f5f96554a00d38afc.tar.gz |
MF libexec/telnetd: MAXHOSTNAMELEN & -u fixes.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/telnet/telnetd/sys_term.c | 3 | ||||
-rw-r--r-- | crypto/telnet/telnetd/telnetd.c | 21 |
2 files changed, 16 insertions, 8 deletions
diff --git a/crypto/telnet/telnetd/sys_term.c b/crypto/telnet/telnetd/sys_term.c index 9c557b1..e8fc3bb 100644 --- a/crypto/telnet/telnetd/sys_term.c +++ b/crypto/telnet/telnetd/sys_term.c @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #endif static const char rcsid[] = - "$Id: sys_term.c,v 1.4 1998/01/22 00:04:57 imp Exp $"; + "$Id: sys_term.c,v 1.5 1998/09/01 15:17:28 gpalmer Exp $"; #endif /* not lint */ #include "telnetd.h" @@ -54,7 +54,6 @@ void scrub_env(void); # define PARENT_DOES_UTMP #endif -int utmp_len = MAXHOSTNAMELEN; #ifdef NEWINIT #include <initreq.h> #else /* NEWINIT*/ diff --git a/crypto/telnet/telnetd/telnetd.c b/crypto/telnet/telnetd/telnetd.c index 76cbf59..8b4798c 100644 --- a/crypto/telnet/telnetd/telnetd.c +++ b/crypto/telnet/telnetd/telnetd.c @@ -42,7 +42,7 @@ static const char copyright[] = static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; #endif static const char rcsid[] = - "$Id: telnetd.c,v 1.5 1998/12/16 06:06:06 peter Exp $"; + "$Id: telnetd.c,v 1.7 1999/04/06 23:35:21 brian Exp $"; #endif /* not lint */ #include "telnetd.h" @@ -93,7 +93,8 @@ int auth_level = 0; int require_SecurID = 0; #endif -extern int utmp_len; +char remote_hostname[UT_HOSTSIZE + 1]; +int utmp_len = sizeof(remote_hostname) - 1; int registerd_host_only = 0; #ifdef STREAMSPTY @@ -386,6 +387,10 @@ main(argc, argv) case 'u': utmp_len = atoi(optarg); + if (utmp_len < 0) + utmp_len = -utmp_len; + if (utmp_len >= sizeof(remote_hostname)) + utmp_len = sizeof(remote_hostname) - 1; break; case 'U': @@ -806,7 +811,6 @@ terminaltypeok(s) char *hostname; char host_name[MAXHOSTNAMELEN]; -char remote_hostname[UT_HOSTSIZE + 1]; extern void telnet P((int, int, char *)); @@ -860,14 +864,19 @@ doit(who) } #endif /* _SC_CRAY_SECURE_SYS */ - /* get name of connected client */ - if (realhostname(remote_hostname, sizeof remote_hostname - 1, + if (realhostname(remote_hostname, sizeof(remote_hostname) - 1, &who->sin_addr) == HOSTNAME_INVALIDADDR && registerd_host_only) fatal(net, "Couldn't resolve your address into a host name.\r\n\ Please contact your net administrator"); + remote_hostname[sizeof(remote_hostname) - 1] = '\0'; + + if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len) + strncpy(remote_hostname, inet_ntoa(who->sin_addr), + sizeof(remote_hostname) - 1); - (void) gethostname(host_name, sizeof (host_name)); + (void) gethostname(host_name, sizeof(host_name) - 1); + host_name[sizeof(host_name) - 1] = '\0'; hostname = host_name; #if defined(AUTHENTICATION) || defined(ENCRYPTION) |