[klibc] [klibc:update-dash] jobs: Don't attempt to access job table for job %0
klibc-bot for Tobias Klauser
tklauser at distanz.ch
Thu Jan 24 19:15:39 PST 2019
Commit-ID: 5f90510fbb7e11f5d4fccb6178a2f6e684b7ce64
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=5f90510fbb7e11f5d4fccb6178a2f6e684b7ce64
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: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] 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 <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 1c6c6fbd..7c324b76 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