From: Sami Kerola Date: Sun, 3 Apr 2016 08:35:29 +0000 (+0100) Subject: chrt: validate priority before trying to use it X-Git-Tag: v2.29-rc1~299 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e31d1c3a5d729c4a9062e37210a1c01623327d6;p=thirdparty%2Futil-linux.git chrt: validate priority before trying to use it Earlier message: $ chrt -i 1 ls chrt: failed to set pid 0's policy: Invalid argument basically told 'something failed', while the new one tries to be more helpful. $ chrt -i 1 ls chrt: unsupported priority value for the policy: 1: see --max for valid range Addresses: https://bugs.debian.org/791707 Signed-off-by: Sami Kerola --- diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 64a58584ff..202ce25268 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -504,7 +504,11 @@ int main(int argc, char **argv) #endif if (ctl->pid == -1) ctl->pid = 0; - + if (ctl->priority < sched_get_priority_min(ctl->policy) || + sched_get_priority_max(ctl->policy) < ctl->priority) + errx(EXIT_FAILURE, + _("unsupported priority value for the policy: %d: see --max for valid range"), + ctl->priority); set_sched(ctl); if (ctl->verbose)