[git commit] ash: jobs: Don't attempt to access job table for job %0

Denys Vlasenko vda.linux at googlemail.com
Wed Sep 28 23:10:08 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=46a45ce02f2c6e775d437c66c5965458bb5d35d8
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

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 at distanz.ch>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index d0c0a51..a31cee2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3654,7 +3654,7 @@ getjob(const char *name, int getctl)
 
 	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 busybox-cvs mailing list