From 87e1afbd93806de284d32e8ad045257b64ab7349 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 17 Jun 1996 14:59:07 +0000 Subject: [PATCH] If hostname > UT_HOSTSIZE, use its numerical address instead to keep valid utmp and wtmp entries --- libexec/ftpd/logwtmp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c index d40840c4bfd7..d08bdba85bd3 100644 --- a/libexec/ftpd/logwtmp.c +++ b/libexec/ftpd/logwtmp.c @@ -37,10 +37,13 @@ static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ #include -#include #include +#include +#include #include +#include +#include #include #include #include @@ -61,6 +64,18 @@ logwtmp(line, name, host) struct utmp ut; struct stat buf; + if (strlen(host) > UT_HOSTSIZE) { + struct hostent *hp = gethostbyname(host); + + if (hp != NULL) { + struct in_addr in; + + memmove(&in, hp->h_addr, sizeof(in)); + host = inet_ntoa(in); + } else + host = "invalid hostname"; + } + if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) return; if (fstat(fd, &buf) == 0) {