From patchwork Thu Dec 10 07:59:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Klauser X-Patchwork-Id: 7815161 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CD694BEEE1 for ; Thu, 10 Dec 2015 07:59:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0158E20395 for ; Thu, 10 Dec 2015 07:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD36B20361 for ; Thu, 10 Dec 2015 07:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754374AbbLJH7u (ORCPT ); Thu, 10 Dec 2015 02:59:50 -0500 Received: from mail.zhinst.com ([212.126.164.98]:56847 "EHLO mail.zhinst.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753279AbbLJH7s (ORCPT ); Thu, 10 Dec 2015 02:59:48 -0500 Received: from ziws06.zhinst.com ([10.42.0.7]) by mail.zhinst.com (Kerio Connect 8.5.3); Thu, 10 Dec 2015 08:59:35 +0100 From: Tobias Klauser To: herbert@gondor.apana.org.au Cc: dash@vger.kernel.org Subject: [PATCH] jobs: Don't attempt to access job table for job %0 Date: Thu, 10 Dec 2015 08:59:34 +0100 Message-Id: <1449734374-23041-1-git-send-email-tklauser@distanz.ch> X-Mailer: git-send-email 2.6.3.368.gf34be46.dirty Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;