diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-12-10 08:59:34 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 4e8511b9af7387ed958094485407e636cd06dcc8 (patch) | |
tree | f62cbe2af9fee69a31855659c6aac798ab007ee0 | |
parent | d310db70cde8a212a463635f7321744ec502fe94 (diff) | |
download | klibc-4e8511b9af7387ed958094485407e636cd06dcc8.tar.gz |
[klibc] dash: jobs: Don't attempt to access job table for job %0
[ dash commit 16cde63e05519c770daa69345b8cf37fb31eaa2a ]
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 <tklauser@distanz.ch>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/jobs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c index c9b631ac0af38..49c14441f51e6 100644 --- a/usr/dash/jobs.c +++ b/usr/dash/jobs.c @@ -698,7 +698,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; |