Source-Changes-HG archive

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

[src/netbsd-8]: src/bin/ps Pull up following revision(s) (requested by kamil ...



details:   https://anonhg.NetBSD.org/src/rev/0c216e90d44e
branches:  netbsd-8
changeset: 434593:0c216e90d44e
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Feb 03 22:11:36 2018 +0000

description:
Pull up following revision(s) (requested by kamil in ticket #515):
        bin/ps/ps.c: revision 1.89
Fix an unitialized memory read bug in ps(1)
rawcpu of type int, is declared inside main(){} and it can be passed as
uninitialized to setpinfo().
The setpinfo() function has a switch checking the value of rawcpu:
  if (!rawcpu)
    pi[i].pcpu /= 1.0 - exp(ki[i].p_swtime * log_ccpu);
rawcpu is set to 1 with the command line argument "-C".
   -C           Change the way the CPU percentage is calculated by using a
                "raw" CPU calculation that ignores "resident" time (this
                normally has no effect).
Bug reproducible with an invocation: "ps u". It hides with "ps uC".
Initialize rawcpu by default to 0, before the getopt(3) machinery.
Detected with MSan running on NetBSD/amd64.
Sponsored by <The NetBSD Foundation>

diffstat:

 bin/ps/ps.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 760d0004138d -r 0c216e90d44e bin/ps/ps.c
--- a/bin/ps/ps.c       Sat Feb 03 22:07:26 2018 +0000
+++ b/bin/ps/ps.c       Sat Feb 03 22:11:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $      */
+/*     $NetBSD: ps.c,v 1.88.6.1 2018/02/03 22:11:36 snj Exp $  */
 
 /*
  * Copyright (c) 2000-2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)ps.c       8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $");
+__RCSID("$NetBSD: ps.c,v 1.88.6.1 2018/02/03 22:11:36 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -224,7 +224,7 @@
        if (argc > 1)
                argv[1] = kludge_oldps_options(argv[1]);
 
-       descendancy = fmt = prtheader = wflag = xflg = showlwps = 0;
+       descendancy = fmt = prtheader = wflag = xflg = rawcpu = showlwps = 0;
        what = KERN_PROC_UID;
        flag = myuid = getuid();
        memf = nlistf = swapf = NULL;



Home | Main Index | Thread Index | Old Index