diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-19 09:03:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-19 09:03:35 +0000 |
commit | 0d02ed46dfdf6ae3e5d5cf378c71e3deee195348 (patch) | |
tree | 0bbaea5d568ff9846477960712ff8f95fa31bd09 | |
parent | 38f7afd720ec7ee0b70bfa06c57c84d00676a0be (diff) |
bye bye sprintf
-rw-r--r-- | usr.bin/systat/iostat.c | 6 | ||||
-rw-r--r-- | usr.bin/systat/mbufs.c | 8 | ||||
-rw-r--r-- | usr.bin/systat/netstat.c | 14 | ||||
-rw-r--r-- | usr.bin/systat/pigs.c | 6 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 8 |
5 files changed, 22 insertions, 20 deletions
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c index 7bd0041f7ea..cd2757da1fe 100644 --- a/usr.bin/systat/iostat.c +++ b/usr.bin/systat/iostat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iostat.c,v 1.9 1997/07/15 14:41:06 kstailey Exp $ */ +/* $OpenBSD: iostat.c,v 1.10 1997/12/19 09:03:32 deraadt Exp $ */ /* $NetBSD: iostat.c,v 1.5 1996/05/10 23:16:35 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: iostat.c,v 1.9 1997/07/15 14:41:06 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: iostat.c,v 1.10 1997/12/19 09:03:32 deraadt Exp $"; #endif not lint #include <sys/param.h> @@ -305,7 +305,7 @@ histogram(val, colwidth, scale) k = MIN(v, colwidth); if (v > colwidth) { - sprintf(buf, "%4.1f", val); + snprintf(buf, sizeof buf, "%4.1f", val); k -= strlen(buf); while (k--) waddch(wnd, 'X'); diff --git a/usr.bin/systat/mbufs.c b/usr.bin/systat/mbufs.c index f1e569a184e..72c13e09d8e 100644 --- a/usr.bin/systat/mbufs.c +++ b/usr.bin/systat/mbufs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbufs.c,v 1.3 1996/06/26 05:40:08 deraadt Exp $ */ +/* $OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $ */ /* $NetBSD: mbufs.c,v 1.2 1995/01/20 08:52:02 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: mbufs.c,v 1.3 1996/06/26 05:40:08 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -102,7 +102,7 @@ void showmbufs() { register int i, j, max, index; - char buf[10]; + char buf[13]; if (mb == 0) return; @@ -121,7 +121,7 @@ showmbufs() mvwprintw(wnd, 1+j, 0, "%-10.10s", mtnames[index]); wmove(wnd, 1 + j, 10); if (max > 60) { - sprintf(buf, " %d", max); + snprintf(buf, sizeof buf, " %d", max); max = 60; while (max--) waddch(wnd, 'X'); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index e5bea81435c..6d69352c89d 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.c,v 1.7 1997/06/23 22:21:48 millert Exp $ */ +/* $OpenBSD: netstat.c,v 1.8 1997/12/19 09:03:33 deraadt Exp $ */ /* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: netstat.c,v 1.7 1997/06/23 22:21:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: netstat.c,v 1.8 1997/12/19 09:03:33 deraadt Exp $"; #endif /* not lint */ /* @@ -388,14 +388,16 @@ inetprint(in, port, proto) struct servent *sp = 0; char line[80], *cp; - sprintf(line, "%.*s.", 16, inetname(*in)); + snprintf(line, sizeof line, "%.*s.", 16, inetname(*in)); cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport(port, proto); if (sp || port == 0) - sprintf(cp, "%.8s", sp ? sp->s_name : "*"); + snprintf(cp, sizeof line - strlen(cp), "%.8s", + sp ? sp->s_name : "*"); else - sprintf(cp, "%d", ntohs((u_short)port)); + snprintf(cp, sizeof line - strlen(cp), "%d", + ntohs((u_short)port)); /* pad to full column to clear any garbage */ cp = strchr(line, '\0'); while (cp - line < 22) @@ -440,7 +442,7 @@ inetname(in) else { in.s_addr = ntohl(in.s_addr); #define C(x) ((x) & 0xff) - sprintf(line, "%u.%u.%u.%u", C(in.s_addr >> 24), + snprintf(line, sizeof line, "%u.%u.%u.%u", C(in.s_addr >> 24), C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr)); } return (line); diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c index b040047dd04..ad156fcc13f 100644 --- a/usr.bin/systat/pigs.c +++ b/usr.bin/systat/pigs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pigs.c,v 1.4 1997/06/23 22:21:48 millert Exp $ */ +/* $OpenBSD: pigs.c,v 1.5 1997/12/19 09:03:33 deraadt Exp $ */ /* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93"; #endif -static char rcsid[] = "$OpenBSD: pigs.c,v 1.4 1997/06/23 22:21:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: pigs.c,v 1.5 1997/12/19 09:03:33 deraadt Exp $"; #endif /* not lint */ /* @@ -132,7 +132,7 @@ showpigs() wmove(wnd, y, 0); wclrtoeol(wnd); mvwaddstr(wnd, y, 0, uname); - sprintf(pidname, "%10.10s", pname); + snprintf(pidname, sizeof pidname, "%10.10s", pname); mvwaddstr(wnd, y, 9, pidname); wmove(wnd, y, 20); for (j = pt[k].pt_pctcpu*factor + 0.5; j > 0; j--) diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 46b611dd889..7da0c31fcfa 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.11 1997/11/24 16:19:42 kstailey Exp $ */ +/* $OpenBSD: vmstat.c,v 1.12 1997/12/19 09:03:34 deraadt Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif -static char rcsid[] = "$OpenBSD: vmstat.c,v 1.11 1997/11/24 16:19:42 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: vmstat.c,v 1.12 1997/12/19 09:03:34 deraadt Exp $"; #endif /* not lint */ /* @@ -604,7 +604,7 @@ putint(n, l, c, w) addch(' '); return; } - sprintf(b, "%*d", w, n); + snprintf(b, sizeof b, "%*d", w, n); if (strlen(b) > w) { while (w-- > 0) addch('*'); @@ -626,7 +626,7 @@ putfloat(f, l, c, w, d, nz) addch(' '); return; } - sprintf(b, "%*.*f", w, d, f); + snprintf(b, sizeof b, "%*.*f", w, d, f); if (strlen(b) > w) { while (--w >= 0) addch('*'); |