diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-22 09:58:44 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-22 09:58:44 +0000 |
commit | bb7eeb6788cc4643c489b2ebe3d081a57e6599b4 (patch) | |
tree | a642a7982ee9f7ac6a914e0fca23aff9381e461a | |
parent | c05033b07a7be4645c27de0a0186e57baf89e72d (diff) |
Fix a trivial truncation case, and eliminate a corner case that might
print a nul character. From atatat@netbsd
-rw-r--r-- | usr.bin/stat/stat.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index f106d734db9..2869464ac49 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stat.c,v 1.9 2005/04/11 08:19:07 otto Exp $ */ +/* $OpenBSD: stat.c,v 1.10 2005/04/22 09:58:43 otto Exp $ */ /* $NetBSD: stat.c,v 1.19 2004/06/20 22:20:16 jmc Exp $ */ /* @@ -39,7 +39,7 @@ #ifndef lint static const char rccs_id[] = - "$OpenBSD: stat.c,v 1.9 2005/04/11 08:19:07 otto Exp $"; + "$OpenBSD: stat.c,v 1.10 2005/04/22 09:58:43 otto Exp $"; #endif #include <sys/types.h> @@ -308,7 +308,7 @@ output(const struct stat *st, const char *file, const char *statfmt, int fn, int nonl) { int flags, size, prec, ofmt, hilo, what; - char buf[PATH_MAX]; + char buf[PATH_MAX + 4 + 1]; const char *subfmt; int nl, t, i; @@ -474,7 +474,7 @@ output(const struct stat *st, const char *file, t = format1(st, file, subfmt, statfmt - subfmt, buf, sizeof(buf), flags, size, prec, ofmt, hilo, what); - for (i = 0; i < t && i < sizeof(buf); i++) + for (i = 0; i < t && i < sizeof(buf) - 1; i++) addchar(stdout, buf[i], &nl); continue; |