]> granicus.if.org Git - procps-ng/commitdiff
top: afford another level of protection for line input <=== port of newlib 757a3452
authorJim Warner <james.warner@comcast.net>
Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 3 Jul 2022 11:33:07 +0000 (21:33 +1000)
______________________________ original newlib message

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 9e3574fc0d14cb793c80b13f298ffe48f9019b89..d6c8060241fe36dfff049755f60e5a2d92858b85 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1423,7 +1423,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;