top: add another tiny bit of robustness to rcfile code
authorJim Warner <james.warner@comcast.net>
Tue, 15 Mar 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 21 Mar 2022 20:43:56 +0000 (07:43 +1100)
At this point I don't know if the Rc.id ever carried a
value of 'b', 'c', 'd' or 'e' in a public release. But
I do know that those values ought not to be recognized
in any configuration file. Now they won't be for sure.

[ while the absence of this new check didn't produce ]
[ an error message, it would skip the initialization ]
[ of default values plus possible string extensions. ]

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

index 0dc55581de454bb9915938654badb31342aebb64..edd3b38f4ce74a3ca470803fe4e3654c2829594f 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4048,6 +4048,8 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
    }
    if (Rc.id < 'a' || Rc.id > RCF_VERSION_ID)
       return p;
+   if (strchr("bcde", Rc.id))
+      return p;
    if (Rc.mode_altscr < 0 || Rc.mode_altscr > 1)
       return p;
    if (Rc.mode_irixps < 0 || Rc.mode_irixps > 1)