]> granicus.if.org Git - procps-ng/commitdiff
top: swat bug affecting batch mode and width provision
authorJim Warner <james.warner@comcast.net>
Thu, 29 Aug 2013 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Fri, 30 Aug 2013 12:08:26 +0000 (22:08 +1000)
Normally, the internally tracked 'Screen_cols' can not
exceed the lessor of 512 or actual screen width. There
was one case, however, where that 512 byte upper limit
was no longer properly imposed as it should have been.

When operating in 'Batch' mode the actual screen width
was allowed to be exceeded when the optional -w switch
was also used. But, it should never have exceeded 512.

This patch ensures the upper limit is always observed.

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721204

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

index bdfcf20af491d7e2d667380ba094adc36ee64fb1..9996fbf8c60420a7db619d42cb26fc74fda40fab 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1792,6 +1792,7 @@ static void adj_geometry (void) {
          if (w_cols && w_cols < W_MIN_COL) w_cols = W_MIN_COL;
          if (w_rows && w_rows < W_MIN_ROW) w_rows = W_MIN_ROW;
       }
+      if (w_cols > SCREENMAX) w_cols = SCREENMAX;
       w_set = 1;
    }