MF libexec/telnetd: MAXHOSTNAMELEN & -u fixes.

git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@45428 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
brian 1999-04-07 10:17:24 +00:00
parent 8229e94407
commit e115c62597
2 changed files with 16 additions and 8 deletions

View File

@ -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*/

View File

@ -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';
(void) gethostname(host_name, sizeof (host_name));
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) - 1);
host_name[sizeof(host_name) - 1] = '\0';
hostname = host_name;
#if defined(AUTHENTICATION) || defined(ENCRYPTION)