ash: jobs: Don't attempt to access job table for job %0
Upstream commit: 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@distanz.ch> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@ -3654,7 +3654,7 @@ getjob(const char *name, int getctl)
|
|||||||
|
|
||||||
if (is_number(p)) {
|
if (is_number(p)) {
|
||||||
num = atoi(p);
|
num = atoi(p);
|
||||||
if (num <= njobs) {
|
if (num > 0 && num <= njobs) {
|
||||||
jp = jobtab + num - 1;
|
jp = jobtab + num - 1;
|
||||||
if (jp->used)
|
if (jp->used)
|
||||||
goto gotit;
|
goto gotit;
|
||||||
|
Reference in New Issue
Block a user