Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/systat Knee-jerk snprintf()-ism.



details:   https://anonhg.NetBSD.org/src/rev/766003518913
branches:  trunk
changeset: 479741:766003518913
user:      jwise <jwise%NetBSD.org@localhost>
date:      Mon Dec 20 17:08:52 1999 +0000

description:
Knee-jerk snprintf()-ism.

diffstat:

 usr.bin/systat/main.c |  7 ++++---
 usr.bin/systat/ps.c   |  8 ++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diffs (71 lines):

diff -r 7161f9a7ecb5 -r 766003518913 usr.bin/systat/main.c
--- a/usr.bin/systat/main.c     Mon Dec 20 16:23:44 1999 +0000
+++ b/usr.bin/systat/main.c     Mon Dec 20 17:08:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.20 1999/12/20 03:45:02 jwise Exp $  */
+/*     $NetBSD: main.c,v 1.21 1999/12/20 17:08:52 jwise Exp $  */
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: main.c,v 1.20 1999/12/20 03:45:02 jwise Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 1999/12/20 17:08:52 jwise Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -100,6 +100,7 @@
 
        egid = getegid();
        (void)setegid(getgid());
+
        while ((ch = getopt(argc, argv, "M:N:w:")) != -1)
                switch(ch) {
                case 'M':
@@ -328,7 +329,7 @@
 
        if (wnd) {
                getyx(stdscr, oy, ox);
-               (void) vsprintf(buf, fmt, ap);
+               (void) vsnprintf(buf, sizeof(buf), fmt, ap);
                clrtoeol();
                standout();
                mvaddstr(CMDLINE, 0, buf);
diff -r 7161f9a7ecb5 -r 766003518913 usr.bin/systat/ps.c
--- a/usr.bin/systat/ps.c       Mon Dec 20 16:23:44 1999 +0000
+++ b/usr.bin/systat/ps.c       Mon Dec 20 17:08:52 1999 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ps.c,v 1.9 1999/12/16 04:41:49 jwise Exp $  */
+/*      $NetBSD: ps.c,v 1.10 1999/12/20 17:08:53 jwise Exp $  */
 
 /*-
  * Copyright (c) 1999
@@ -46,7 +46,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ps.c,v 1.9 1999/12/16 04:41:49 jwise Exp $");
+__RCSID("$NetBSD: ps.c,v 1.10 1999/12/20 17:08:53 jwise Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -207,7 +207,7 @@
        if ((flag & P_CONTROLT) && e->e_pgid == e->e_tpgid)
                *cp++ = '+';
        *cp = '\0';
-       sprintf(statestr, "%-s",  buf);
+       snprintf(statestr, sizeof(statestr), "%-s",  buf);
 
        return statestr;
 }
@@ -228,7 +228,7 @@
                if (strncmp(ttyname, "tty", 3) == 0 ||
                    strncmp(ttyname, "dty", 3) == 0)
                        ttyname += 3;
-               sprintf(ttystr, "%s%c", ttyname, e->e_flag & EPROC_CTTY ? ' ' : '-');
+               snprintf(ttystr, sizeof(ttystr), "%s%c", ttyname, e->e_flag & EPROC_CTTY ? ' ' : '-');
        }
 
        return ttystr;



Home | Main Index | Thread Index | Old Index