]> granicus.if.org Git - procps-ng/commitdiff
top: needed 'Ctrl' bottom window fixes were discovered
authorJim Warner <james.warner@comcast.net>
Sun, 15 May 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 16 May 2022 10:06:18 +0000 (20:06 +1000)
As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.

While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.

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

index 1597d4c0ec9ad155208fb186a79728aa0cdc6dc6..5ba6a571a1db69c7050ac2f3016851d1cef33f95 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4758,7 +4758,7 @@ static void forest_begin (WIN_t *q) {
             eu_TREE_ADD (u_int):  where a children's tics stored (maybe) | */
       for (i = 0; i < Hide_tot; i++) {
 
-        // if have xtra-procps-debug.h, cannpt use PID_VAL w/ assignment |
+        // if have xtra-procps-debug.h, cannot use PID_VAL w/ assignment |
        #define rSv(E,T,X)  Tree_ppt[X]->head[E].result.T
        #define rSv_Pid(X)  rSv(EU_PID, s_int, X)
        #define rSv_Lvl(X)  rSv(eu_TREE_LVL, s_int, X)
@@ -4859,7 +4859,7 @@ static inline const char *forest_display (const WIN_t *q, int idx) {
  #define rSv_Lvl  PID_VAL(eu_TREE_LVL, s_int, p)
  #define rSv_Hid  PID_VAL(eu_TREE_HID, s_ch, p)
 #ifndef SCROLLVAR_NO
-   static char buf[1024*64*2]; // the same as libray's max buffer size
+   static char buf[MAXBUFSIZ];
 #else
    static char buf[ROWMINSIZ];
 #endif
@@ -4918,12 +4918,12 @@ static void bot_do (const char *str, int focus) {
         /*
          * This guy draws that bottom window's header |
          * then parses/arranges to show the contents. |
-         * ( returns the number of elements printed ) | */
+         * ( returns relative # of elements printed ) | */
 static int bot_focus (const char *hdr, const char *str) {
  #define maxRSVD ( Screen_rows - 1 )
-   static char sav[BIGBUFSIZ*2];
+   static char sav[BOTBUFSIZ];
    const char *end, *beg;
-   char tmp[SCREENMAX];
+   char tmp[BIGBUFSIZ];
    int n, x;
 
    if (str) {
@@ -5119,7 +5119,7 @@ static void bot_pick_toggle (void) {
       Bot_what = BOT_MENU_ON;
       Bot_indx = 0;
       Bot_item[0] = BOT_DELIMIT;
-      Bot_name = (char*)"a menu, please choose among the following ...";
+      Bot_name = (char*)"a menu, please choose among the following, then press <Enter> ...";
       Bot_func = bot_pick_show;
       Bot_task = PID_VAL(EU_PID, s_int, Curwin->ppt[Curwin->begtask]);
    }
index b1367f7785bbc4a4b0a5f3d84c23f2f8dd0abe1b..7c9713ebce59e43f85eff9d7243c4e89a8b1bca2 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -141,6 +141,9 @@ char *strcasestr(const char *haystack, const char *needle);
 #define LRGBUFSIZ   512
 #define OURPATHSZ  1024
 #define BIGBUFSIZ  2048
+#define BOTBUFSIZ 16384
+        // next is same as library's max buffer size
+#define MAXBUFSIZ (1024*64*2)
    /* in addition to the actual display data, our row might have to accommodate
       many termcap/color transitions - these definitions ensure we have room */
 #define ROWMINSIZ  ( SCREENMAX +  8 * (CAPBUFSIZ + CLRBUFSIZ) )