]> granicus.if.org Git - procps-ng/commitdiff
top: Prevent buffer overflow in calibrate_... REVERTED
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:43:08 +0000 (21:43 +1000)
Here, again, we have an example of attacking a problem
by addressing the symptoms. And that assertion made in
the original commit message is true if only if someone
had manually (maliciously) edited the top config file.

So let's reverse the original patch & thus prepare for
a proper solution addressing the cause, not a symptom.

Reference(s):
. original qualys patch
0114-top-Prevent-buffer-overflow-in-calibrate_fields.patch
commit c424a643318abfb534a692bd86c6a5e411ed2ebb

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

index 308378dbff91c1cb44984af957fcc18af8e54323..80040f00c2cc0ff8ed1eb635d115511a9811ddf8 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -2130,13 +2130,12 @@ static void calibrate_fields (void) {
          w->hdrcaplen = 0;   // really only used with USE_X_COLHDR
          // build window's pflgsall array, establish upper bounds for maxpflgs
          for (i = 0, w->totpflgs = 0; i < EU_MAXPFLGS; i++) {
-            if (FLDviz(w, i) && w->totpflgs < PFLAGSSIZ) {
+            if (FLDviz(w, i)) {
                f = FLDget(w, i);
 #ifdef USE_X_COLHDR
                w->pflgsall[w->totpflgs++] = f;
 #else
-               if (CHKw(w, Show_HICOLS) && f == w->rc.sortindx &&
-                  w->totpflgs <= PFLAGSSIZ - 3) {
+               if (CHKw(w, Show_HICOLS) && f == w->rc.sortindx) {
                   w->pflgsall[w->totpflgs++] = EU_XON;
                   w->pflgsall[w->totpflgs++] = f;
                   w->pflgsall[w->totpflgs++] = EU_XOF;