From: Jim Warner Date: Sun, 26 Jun 2022 05:00:00 +0000 (-0500) Subject: top: afford another level of protection for line input <=== port of newlib 757a3452 X-Git-Tag: v4.0.3_rc1~33^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1750dd2b96577ac2ca51666ca4ba1da38bcb60e9;p=procps-ng top: afford another level of protection for line input <=== port of newlib 757a3452 ______________________________ 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 --- diff --git a/top/top.c b/top/top.c index 9e3574fc..d6c80602 100644 --- 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;