NetBSD/bin/ps
kamil 0e68b604ab 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>
2018-01-12 23:01:14 +00:00
..
Makefile Document non-literal formats 2011-08-14 10:53:16 +00:00
extern.h ps: Rename local routine name from uname to usrname 2017-12-09 14:56:54 +00:00
fmt.c
keyword.c ps: Rename local routine name from uname to usrname 2017-12-09 14:56:54 +00:00
nlist.c for donlist{,_sysctl}: 2016-11-28 08:19:23 +00:00
print.c ps: Rename local routine name from uname to usrname 2017-12-09 14:56:54 +00:00
ps.1 Bump date for previous. Remove/replace bogus Tn uses. 2017-08-28 05:57:37 +00:00
ps.c Fix an unitialized memory read bug in ps(1) 2018-01-12 23:01:14 +00:00
ps.h provide a tree like display with -d, from FreeBSD 2016-12-02 21:59:03 +00:00