top: provide the means to exploit a 256-color terminal
With the Qualys security audit, we began to harden our treatment of the top rcfile. In particular, the values read were checked so as to prevent some malicious user from editing it in order to achieve an evil objective. However when it came to colors I was surprised to find that at least one user edited the rcfile for 256-color support. Unfortunately, our new checks prevented this. So this commit will provide the means to exploit those extra colors with no need to manually edit the rcfile. Reference(s): https://gitlab.com/procps-ng/procps/issues/96 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
21
top/top.c
21
top/top.c
@@ -3293,10 +3293,11 @@ static const char *config_file (FILE *fp, const char *name, float *delay) {
|
||||
if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
||||
, &w->rc.summclr, &w->rc.msgsclr, &w->rc.headclr, &w->rc.taskclr))
|
||||
return p;
|
||||
if (w->rc.summclr < 0 || w->rc.summclr > 7) return p;
|
||||
if (w->rc.msgsclr < 0 || w->rc.msgsclr > 7) return p;
|
||||
if (w->rc.headclr < 0 || w->rc.headclr > 7) return p;
|
||||
if (w->rc.taskclr < 0 || w->rc.taskclr > 7) return p;
|
||||
// would prefer to use 'max_colors', but it isn't available yet...
|
||||
if (w->rc.summclr < 0 || w->rc.summclr > 255) return p;
|
||||
if (w->rc.msgsclr < 0 || w->rc.msgsclr > 255) return p;
|
||||
if (w->rc.headclr < 0 || w->rc.headclr > 255) return p;
|
||||
if (w->rc.taskclr < 0 || w->rc.taskclr > 255) return p;
|
||||
|
||||
switch (Rc.id) {
|
||||
case 'a': // 3.2.8 (former procps)
|
||||
@@ -3880,7 +3881,7 @@ signify_that:
|
||||
putp(Cap_home);
|
||||
// this string is well above ISO C89's minimum requirements!
|
||||
show_special(1, fmtmk(N_unq(COLOR_custom_fmt)
|
||||
, PACKAGE_STRING, w->grpname
|
||||
, w->grpname
|
||||
, CHKw(w, View_NOBOLD) ? N_txt(ON_word_only_txt) : N_txt(OFF_one_word_txt)
|
||||
, CHKw(w, Show_COLORS) ? N_txt(ON_word_only_txt) : N_txt(OFF_one_word_txt)
|
||||
, CHKw(w, Show_HIBOLD) ? N_txt(ON_word_only_txt) : N_txt(OFF_one_word_txt)
|
||||
@@ -3918,6 +3919,16 @@ signify_that:
|
||||
clr = key - '0';
|
||||
*pclr = clr;
|
||||
break;
|
||||
case kbd_UP:
|
||||
++clr;
|
||||
if (clr >= max_colors) clr = 0;
|
||||
*pclr = clr;
|
||||
break;
|
||||
case kbd_DOWN:
|
||||
--clr;
|
||||
if (clr < 0) clr = max_colors - 1;
|
||||
*pclr = clr;
|
||||
break;
|
||||
case 'B':
|
||||
TOGw(w, View_NOBOLD);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user