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) {