diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-24 23:17:08 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-07-24 23:17:08 +0000 |
commit | 37ef37f9de8565363b1dca6c9bbc71c54e3f3a42 (patch) | |
tree | 5a4c85fe5208ec3d511a801b6afb232fd92547bc /libexec/ftpd/ftpd.c | |
parent | ac9c8f5c6b291b4d5b3486d05195a036e56ed09e (diff) |
Also check for snprintf() returning < 0
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r-- | libexec/ftpd/ftpd.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 196cc76829f..d44993dd3fa 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.133 2002/07/24 23:10:01 millert Exp $ */ +/* $OpenBSD: ftpd.c,v 1.134 2002/07/24 23:17:07 millert Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -74,7 +74,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.133 2002/07/24 23:10:01 millert Exp $"; + "$OpenBSD: ftpd.c,v 1.134 2002/07/24 23:17:07 millert Exp $"; #endif #endif /* not lint */ @@ -2788,17 +2788,18 @@ logxfer(name, size, start) strvis(vremotehost, remotehost, VIS_SAFE|VIS_NOSLASH); strvis(vpw, guest? guestpw : pw->pw_name, VIS_SAFE|VIS_NOSLASH); - len = snprintf(buf, sizeof(buf), + if ((len = snprintf(buf, sizeof(buf), "%.24s %d %s %qd %s %c %s %c %c %s ftp %d %s %s\n", ctime(&now), now - start + (now == start), - vremotehost, (long long) size, vpath, + vremotehost, (long long)size, vpath, ((type == TYPE_A) ? 'a' : 'b'), "*" /* none yet */, 'o', ((guest) ? 'a' : 'r'), vpw, 0 /* none yet */, - ((guest) ? "*" : pw->pw_name), dhostname); - if (len >= sizeof(buf)) { - len = sizeof(buf); - buf[sizeof(buf) - 1] = '\n'; + ((guest) ? "*" : pw->pw_name), dhostname)) >= sizeof(buf) + || len < 0) { + if ((len = strlen(buf)) == 0) + return; /* should not happen */ + buf[len - 1] = '\n'; } write(statfd, buf, len); free(vpw); |