From patchwork Wed Jan 9 07:36:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1950961 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0A0B63FC5A for ; Wed, 9 Jan 2013 07:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757278Ab3AIHgh (ORCPT ); Wed, 9 Jan 2013 02:36:37 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:47691 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751987Ab3AIHgh (ORCPT ); Wed, 9 Jan 2013 02:36:37 -0500 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r097aUfh024275 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Jan 2013 07:36:31 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r097aU7v006562 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Jan 2013 07:36:30 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r097aTBk030807; Wed, 9 Jan 2013 01:36:29 -0600 Received: from elgon.mountain (/41.212.103.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Jan 2013 23:36:29 -0800 Date: Wed, 9 Jan 2013 10:36:32 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab , Michael Hunold Cc: Jonathan Nieder , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [media] dvb-usb: reading before start of array Message-ID: <20130109073632.GD2454@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This is a static checker fix. In the ttusb_process_muxpack() we do: cc = (muxpack[len - 4] << 8) | muxpack[len - 3]; That means if we pass a number less than 4 then we will either trigger a checksum error message or read before the start of the array. Signed-off-by: Dan Carpenter --- I can't test this. This patch doesn't introduce any bugs, but I'm not positive this is the right thing to do. Perhaps it's better to print an error message? -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c index 5b682cc..99a2fd1 100644 --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c @@ -709,7 +709,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len) * if length is valid and we reached the end: * goto next muxpack */ - if ((ttusb->muxpack_ptr >= 2) && + if ((ttusb->muxpack_ptr >= 4) && (ttusb->muxpack_ptr == ttusb->muxpack_len)) { ttusb_process_muxpack(ttusb,