summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-12-04 18:00:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-12-04 18:00:44 +0000
commit20eeebec9f2d042124148e79ecc26c802a32c317 (patch)
treefed6362501fc362cc95dda390d5733c7ef466b99 /libexec
parent574ecaad13b64447ec4608bb7d86cae17f7e9957 (diff)
reply() used to play a lot with stdout, expecially fflush(stdout).
The recent change is to avoid stdio. That's good, except there are nearly 130 calls to this function, yet what if one of them depended on fflush() or something else in this code? The semantic change was never checked. That is not how we do development -- back this out until we know that checking work has been done.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpcmd.y5
-rw-r--r--libexec/ftpd/ftpd.c34
2 files changed, 20 insertions, 19 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 1f2ab22fdb5..2f774c30882 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpcmd.y,v 1.45 2004/12/03 23:57:40 moritz Exp $ */
+/* $OpenBSD: ftpcmd.y,v 1.46 2004/12/04 18:00:43 deraadt 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.45 2004/12/03 23:57:40 moritz Exp $";
+ "$OpenBSD: ftpcmd.y,v 1.46 2004/12/04 18:00:43 deraadt Exp $";
#endif
#endif /* not lint */
@@ -1170,6 +1170,7 @@ 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 82206351a02..a27bba5693b 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.160 2004/12/03 23:57:40 moritz Exp $ */
+/* $OpenBSD: ftpd.c,v 1.161 2004/12/04 18:00:43 deraadt 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.160 2004/12/03 23:57:40 moritz Exp $";
+ "$OpenBSD: ftpd.c,v 1.161 2004/12/04 18:00:43 deraadt Exp $";
#endif
#endif /* not lint */
@@ -1907,27 +1907,27 @@ fatal(char *s)
void
reply(int n, const char *fmt, ...)
{
- char *p, *next;
- char msg[BUFSIZ];
- char buf[BUFSIZ];
+ char *buf, *p, *next;
+ int rval;
va_list ap;
- struct syslog_data sdata = SYSLOG_DATA_INIT;
va_start(ap, fmt);
- vsnprintf(msg, sizeof(msg), fmt, ap);
+ rval = vasprintf(&buf, fmt, ap);
va_end(ap);
-
- next = msg;
-
+ if (rval == -1 || buf == NULL) {
+ printf("412 Local resource failure: malloc\r\n");
+ fflush(stdout);
+ dologout(1);
+ }
+ next = buf;
while ((p = strsep(&next, "\n\r"))) {
- 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);
- }
+ printf("%d%s %s\r\n", n, (next != '\0') ? "-" : "", p);
+ if (debug)
+ syslog(LOG_DEBUG, "<--- %d%s %s", n,
+ (next != '\0') ? "-" : "", p);
}
+ (void)fflush(stdout);
+ free(buf);
}
void