From 16cde63e05519c770daa69345b8cf37fb31eaa2a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 10 Dec 2015 08:59:34 +0100 Subject: jobs: Don't attempt to access job table for job %0 If job %0 is (mistakenly) specified, an out-of-bounds access to the jobtab occurs in function getjob() if num = 0: jp = jobtab + 0 - 1 Fix this by checking that the job number is larger than 0 before accessing the jobtab. Signed-off-by: Tobias Klauser Signed-off-by: Herbert Xu --- src/jobs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/jobs.c') diff --git a/src/jobs.c b/src/jobs.c index c2c2332..3997863 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -699,7 +699,7 @@ check: if (is_number(p)) { num = atoi(p); - if (num <= njobs) { + if (num > 0 && num <= njobs) { jp = jobtab + num - 1; if (jp->used) goto gotit; -- cgit 1.4.1