]> granicus.if.org Git - procps-ng/commitdiff
top: concede integer overflow risks in procs_refresh()
authorJim Warner <james.warner@comcast.net>
Fri, 18 May 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 19 May 2018 11:38:19 +0000 (21:38 +1000)
This is as far as we need go with respect to the issue
of integer overflow addressed in that reference below.

That patch, of course, was reversed to prepare for us.

Reference(s):
. original qualys patch
0105-top-Prevent-integer-overflows-in-procs_refresh.patch
commit 131e5e2fe63f29edfc7df04b2b2a1682d93af846

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 00a59e5cb4f43a1b7682841bc20a3b4492af68b0..47f4bdcb8948c5125abb5fd03a5c6bd154a5f613 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -2797,6 +2797,8 @@ static void procs_hlp (proc_t *this) {
    }
 
    if (Frame_maxtask+1 >= HHist_siz) {
+      /* we're subject to integer overflow if total linux tasks ever approach |
+         400+ million (but, do you think memory might be the bigger problem?) | */
       HHist_siz = HHist_siz * 5 / 4 + 100;
       PHist_sav = alloc_r(PHist_sav, sizeof(HST_t) * HHist_siz);
       PHist_new = alloc_r(PHist_new, sizeof(HST_t) * HHist_siz);
@@ -2859,6 +2861,8 @@ static void procs_refresh (void) {
 
    for (;;) {
       if (n_used == n_alloc) {
+         /* we're subject to integer overflow if total linux tasks ever approach |
+            400+ million (but, do you think memory might be the bigger problem?) | */
          n_alloc = 10 + ((n_alloc * 5) / 4);     // grow by over 25%
          private_ppt = alloc_r(private_ppt, sizeof(proc_t*) * n_alloc);
          // ensure NULL pointers for the additional memory just acquired