diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-12-06 23:04:15 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-12-06 23:04:15 +0000 |
commit | f41c154ac05ca2876af616579040e3046d65ed70 (patch) | |
tree | 444670cb824b0a29e0e95bc17195a899769dd266 /libexec/ftpd/ftpd.c | |
parent | 6362781442cf20ec59e6550787b8b741d379fca9 (diff) |
seperate reply_r, like earlier change but safer; moritz ok
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r-- | libexec/ftpd/ftpd.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index a27bba5693b..980abca47d3 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.161 2004/12/04 18:00:43 deraadt Exp $ */ +/* $OpenBSD: ftpd.c,v 1.162 2004/12/06 23:04:14 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.161 2004/12/04 18:00:43 deraadt Exp $"; + "$OpenBSD: ftpd.c,v 1.162 2004/12/06 23:04:14 deraadt Exp $"; #endif #endif /* not lint */ @@ -1930,6 +1930,33 @@ reply(int n, const char *fmt, ...) free(buf); } + +void +reply_r(int n, const char *fmt, ...) +{ + char *p, *next; + char msg[BUFSIZ]; + char buf[BUFSIZ]; + va_list ap; + struct syslog_data sdata = SYSLOG_DATA_INIT; + + va_start(ap, fmt); + vsnprintf(msg, sizeof(msg), fmt, ap); + va_end(ap); + + next = msg; + + 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); + } + } +} + void lreply(int n, const char *fmt, ...) { |