dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jobs: Don't attempt to access job table for job %0
@ 2015-12-10  7:59 Tobias Klauser
  2016-06-06 11:57 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Klauser @ 2015-12-10  7:59 UTC (permalink / raw)
  To: herbert; +Cc: dash

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>
---
 src/jobs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/jobs.c b/src/jobs.c
index c2c2332a25fa..39978635d891 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -699,7 +699,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;
-- 
2.6.3.368.gf34be46.dirty



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: jobs: Don't attempt to access job table for job %0
  2015-12-10  7:59 [PATCH] jobs: Don't attempt to access job table for job %0 Tobias Klauser
@ 2016-06-06 11:57 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2016-06-06 11:57 UTC (permalink / raw)
  To: Tobias Klauser; +Cc: dash

On Thu, Dec 10, 2015 at 08:59:34AM +0100, Tobias Klauser wrote:
> 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>

Patch applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-06 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10  7:59 [PATCH] jobs: Don't attempt to access job table for job %0 Tobias Klauser
2016-06-06 11:57 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).