From: Jim Warner Date: Sat, 30 Jun 2012 05:00:33 +0000 (-0500) Subject: top: improve unsolicited user input validation X-Git-Tag: v3.3.4~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22515ce62e3dd759e1b1ccacf3782980f4f1dc64;p=procps-ng top: improve unsolicited user input validation The logic associated with invalid keystrokes was simplified through some minor reordering. Signed-off-by: Jim Warner --- diff --git a/top/top.c b/top/top.c index 1783ab38..2148f162 100644 --- a/top/top.c +++ b/top/top.c @@ -3488,16 +3488,11 @@ static void do_key (int ch) { for (i = 0; i < MAXTBL(key_tab); ++i) if (strchr(key_tab[i].keys, ch)) { key_tab[i].func(ch); - break; + Frames_resize = 1; + return; } - - if (!(i < MAXTBL(key_tab))) { - show_msg(N_txt(UNKNOWN_cmds_txt)); - return; - } }; - - /* The following assignment will force a rebuild of all column headers and + /* Frames_resize above will force a rebuild of all column headers and the PROC_FILLxxx flags. It's NOT simply lazy programming. Here are some keys that COULD require new column headers and/or libproc flags: 'A' - likely @@ -3516,7 +3511,8 @@ static void do_key (int ch) { ( At this point we have a human being involved and so have all the time ) ( in the world. We can afford a few extra cpu cycles every now & then! ) */ - Frames_resize = 1; + + show_msg(N_txt(UNKNOWN_cmds_txt)); } // end: do_key