diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-17 07:17:19 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-17 07:17:19 +0000 |
commit | 86440b250b5f8f21d0e803017969624f017f9c6f (patch) | |
tree | 3c0d6ecdb1223c13513fa264a0e2710a5a474fc4 /usr.bin/window | |
parent | 9272a29e3986b4b27a23b7dfc928a11d5af6cfe4 (diff) |
trivial snprintf
Diffstat (limited to 'usr.bin/window')
-rw-r--r-- | usr.bin/window/lcmd2.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/window/lcmd2.c b/usr.bin/window/lcmd2.c index 25e6a77c4b2..ef711ea5ac1 100644 --- a/usr.bin/window/lcmd2.c +++ b/usr.bin/window/lcmd2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcmd2.c,v 1.6 2003/04/05 01:39:50 pvalchev Exp $ */ +/* $OpenBSD: lcmd2.c,v 1.7 2003/04/17 07:17:18 deraadt Exp $ */ /* $NetBSD: lcmd2.c,v 1.7 1995/09/29 00:44:04 cgd Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lcmd2.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lcmd2.c,v 1.6 2003/04/05 01:39:50 pvalchev Exp $"; +static char rcsid[] = "$OpenBSD: lcmd2.c,v 1.7 2003/04/17 07:17:18 deraadt Exp $"; #endif #endif /* not lint */ @@ -161,7 +161,8 @@ struct timeval *t; char *p = buf; if (t->tv_sec > 60*60) { - (void) sprintf(p, "%ld:", t->tv_sec / (60*60)); + (void) snprintf(p, buf + sizeof buf - p, + "%ld:", t->tv_sec / (60*60)); while (*p++) ; p--; @@ -169,14 +170,16 @@ struct timeval *t; fill++; } if (t->tv_sec > 60) { - (void) sprintf(p, fill ? "%02ld:" : "%ld:", t->tv_sec / 60); + (void) snprintf(p, buf + sizeof buf - p, + fill ? "%02ld:" : "%ld:", t->tv_sec / 60); while (*p++) ; p--; t->tv_sec %= 60; fill++; } - (void) sprintf(p, fill ? "%02ld.%02d" : "%ld.%02ld", + (void) snprintf(p, buf + sizeof buf - p, + fill ? "%02ld.%02d" : "%ld.%02ld", t->tv_sec, t->tv_usec / 10000); return buf; } |