[klibc] [klibc:update-dash] dash: jobs: Don't attempt to access job table for job %0
klibc-bot for Tobias Klauser
tklauser at distanz.ch
Sat Mar 28 14:48:45 PDT 2020
Commit-ID: 4e8511b9af7387ed958094485407e636cd06dcc8
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=4e8511b9af7387ed958094485407e636cd06dcc8
Author: Tobias Klauser <tklauser at distanz.ch>
AuthorDate: Thu, 10 Dec 2015 08:59:34 +0100
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:54 +0000
[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 at distanz.ch>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/jobs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c
index c9b631ac..49c14441 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;
More information about the klibc
mailing list