summaryrefslogtreecommitdiff
path: root/libexec/ftpd
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpcmd.y5
-rw-r--r--libexec/ftpd/ftpd.c34
2 files changed, 19 insertions, 20 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index c4673356199..1f2ab22fdb5 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpcmd.y,v 1.44 2004/11/28 18:49:29 henning Exp $ */
+/* $OpenBSD: ftpcmd.y,v 1.45 2004/12/03 23:57:40 moritz Exp $ */
/* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */
/*
@@ -44,7 +44,7 @@
static const char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94";
#else
static const char rcsid[] =
- "$OpenBSD: ftpcmd.y,v 1.44 2004/11/28 18:49:29 henning Exp $";
+ "$OpenBSD: ftpcmd.y,v 1.45 2004/12/03 23:57:40 moritz Exp $";
#endif
#endif /* not lint */
@@ -1170,7 +1170,6 @@ toolong(signo)
{
struct syslog_data sdata = SYSLOG_DATA_INIT;
- /* XXX signal races */
reply(421,
"Timeout (%d seconds): closing control connection.", timeout);
if (logging)
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 66b5ce7e170..82206351a02 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.159 2004/11/28 22:29:44 henning Exp $ */
+/* $OpenBSD: ftpd.c,v 1.160 2004/12/03 23:57:40 moritz Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -70,7 +70,7 @@ static const char copyright[] =
static const char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
#else
static const char rcsid[] =
- "$OpenBSD: ftpd.c,v 1.159 2004/11/28 22:29:44 henning Exp $";
+ "$OpenBSD: ftpd.c,v 1.160 2004/12/03 23:57:40 moritz Exp $";
#endif
#endif /* not lint */
@@ -1907,27 +1907,27 @@ fatal(char *s)
void
reply(int n, const char *fmt, ...)
{
- char *buf, *p, *next;
- int rval;
+ char *p, *next;
+ char msg[BUFSIZ];
+ char buf[BUFSIZ];
va_list ap;
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
va_start(ap, fmt);
- rval = vasprintf(&buf, fmt, ap);
+ vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
- if (rval == -1 || buf == NULL) {
- printf("412 Local resource failure: malloc\r\n");
- fflush(stdout);
- dologout(1);
- }
- next = buf;
+
+ next = msg;
+
while ((p = strsep(&next, "\n\r"))) {
- printf("%d%s %s\r\n", n, (next != '\0') ? "-" : "", p);
- if (debug)
- syslog(LOG_DEBUG, "<--- %d%s %s", n,
- (next != '\0') ? "-" : "", p);
+ snprintf(buf, sizeof(buf), "%d%s %s\r\n", n,
+ (next != '\0') ? "-" : "", p);
+ write(STDOUT_FILENO, buf, strlen(buf));
+ if (debug) {
+ buf[strlen(buf) - 2] = '\0';
+ syslog_r(LOG_DEBUG, &sdata, "<--- %s", buf);
+ }
}
- (void)fflush(stdout);
- free(buf);
}
void