From 97a989cbcde76e1c8b57da4ead819e09dd76f3f1 Mon Sep 17 00:00:00 2001 From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] top: Check Rc.fixed_widest. Otherwise it leads to crashes (for example, setting it to 2147483600 in the configuration file segfaults top). --- top/top.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index b73be426..d58376a6 100644 --- a/top/top.c +++ b/top/top.c @@ -3749,6 +3749,8 @@ error Hey, fix the above fscanf 'PFLAGSSIZ' dependency ! if (fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n" , &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress)) ; // avoid -Wunused-result + if (Rc.fixed_widest < -1 || Rc.fixed_widest > SCREENMAX) + Rc.fixed_widest = 0; // we'll start off Inspect stuff with 1 'potential' blank line // ( only realized if we end up with Inspect.total > 0 ) @@ -4768,7 +4770,7 @@ static void keys_global (int ch) { case 'X': { int wide = get_int(fmtmk(N_fmt(XTRA_fixwide_fmt), Rc.fixed_widest)); if (wide > GET_NUM_NOT) { - if (wide > -1) Rc.fixed_widest = wide; + if (wide >= 0 && wide <= SCREENMAX) Rc.fixed_widest = wide; else Rc.fixed_widest = -1; } }