$NetBSD: patch-ai,v 1.7 2000/06/26 20:09:35 rh Exp $

--- src/ftpd.c.orig	Mon Jun 26 21:52:06 2000
+++ src/ftpd.c	Mon Jun 26 21:52:06 2000
@@ -75,6 +75,7 @@
 #include <grp.h>
 #endif
 #include <sys/stat.h>
+#include <utmp.h>
 
 #define VA_LOCAL_DECL	va_list ap;
 #define VA_START(f)	va_start(ap, f)
@@ -88,6 +89,9 @@
 #ifdef HAVE_SYS_FS_UFS_QUOTA_H
 #include <sys/fs/ufs_quota.h>
 #endif
+#ifdef HAVE_UFS_UFS_QUOTA_H
+#include <ufs/ufs/quota.h>
+#endif
 
 #ifdef HAVE_SYS_SYSLOG_H
 #include <sys/syslog.h>
@@ -2296,7 +2300,8 @@
     (void) seteuid((uid_t) 0);
     if (logged_in)
 	if (wtmp_logging)
-	    wu_logwtmp(ttyline, pw->pw_name, remotehost, 0);
+	    wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 0);
     pw = NULL;
 #ifdef AFS_AUTH
     ktc_ForgetAllTokens();
@@ -2785,7 +2790,8 @@
 #ifdef DEBUG
 	syslog(LOG_DEBUG, "about to call wtmp");
 #endif
-	wu_logwtmp(ttyline, pw->pw_name, remotehost, 1);
+	wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 1);
     }
     logged_in = 1;
 
@@ -5317,7 +5323,9 @@
 		*p = '\0';
 
 	    /* send a line...(note that this overrides dolreplies!) */
+	    VA_START(fmt);
 	    vreply(USE_REPLY_LONG | USE_REPLY_NOTFMT, n, ptr, ap);
+	    VA_END; /* *NEVER* send a 0 as an ap, some machines use a *struct* for a va_list! */
 
 	    if (p)
 		ptr = p + 1;	/* set to the next line... (\0 is handled in the while) */
@@ -5941,6 +5949,8 @@
 	(void) seteuid((uid_t) 0);
 	if (wtmp_logging)
 	    wu_logwtmp(ttyline, pw->pw_name, remotehost, 0);
+	    wu_logwtmp(ttyline, pw->pw_name, strlen(remotehost) > UT_HOSTSIZE
+		       ? remoteaddr : remotehost, 0);
     }
     if (logging)
 	syslog(LOG_INFO, "FTP session closed");
