]> granicus.if.org Git - procps-ng/commitdiff
top: afford another level of protection for line input
authorJim Warner <james.warner@comcast.net>
Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 26 Jun 2022 09:22:00 +0000 (19:22 +1000)
This commit just provides the final protection against
possible screen corruption when processing line input.

[ such corruption was limited to the input line only ]

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

index 6227ff19d0878d78f4f9fb2fca6bb133f47610fa..8868e9dcdd0c83962f50eadaba6969585c291433 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1341,7 +1341,7 @@ static char *ioline (const char *prompt) {
             pos = strlen(buf);
             break;
          default:                      // what we REALLY wanted (maybe)
-            if (bufNXT < bufMAX && scrNXT < Screen_cols) {
+            if (bufNXT < bufMAX && scrNXT < Screen_cols && strlen(buf) < bufMAX) {
                int tot = UTF8_tab[(unsigned char)key],
                    sav = pos;
                if (tot < 1) tot = 1;