From patchwork Mon Apr 1 14:50:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 2371211 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 7C6363FDDA for ; Mon, 1 Apr 2013 14:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758472Ab3DAOuu (ORCPT ); Mon, 1 Apr 2013 10:50:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52895 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752599Ab3DAOuu (ORCPT ); Mon, 1 Apr 2013 10:50:50 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r31Eonmv000645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Apr 2013 10:50:49 -0400 Received: from pedra (vpn1-6-126.gru2.redhat.com [10.97.6.126]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r31EolRO013658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 1 Apr 2013 10:50:48 -0400 Received: from v4l by pedra with local (Exim 4.80.1) (envelope-from ) id 1UMg4M-0005HF-Vj; Mon, 01 Apr 2013 11:50:47 -0300 From: Mauro Carvalho Chehab Cc: Dan Carpenter , Mauro Carvalho Chehab , Linux Media Mailing List Subject: [PATCH] [media] siano: Fix array boundary at smscore_translate_msg() Date: Mon, 1 Apr 2013 11:50:45 -0300 Message-Id: <1364827845-20070-1-git-send-email-mchehab@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As reported by Dan Carpenter: FYI, there are new smatch warnings show up in tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master head: da17d7bda957ae4697b6abc0793f74fb9b50b58f commit: 4c3bdb5e2f5612ceb99ac17dbbe673b59a94d105 [media] siano: better debug send/receive messages drivers/media/common/siano/smscoreapi.c:396 smscore_translate_msg() error: buffer overflow 'siano_msgs' 401 <= 401 While it is almost impossible for this error to happen in practice, as it would require the siano's firmware to return an special invalid answer to a message request, fixing it is trivial. So, let's do it. Reported-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smscoreapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index ebb9ece..45ac9ee 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -389,7 +389,7 @@ char *smscore_translate_msg(enum msg_types msgtype) int i = msgtype - MSG_TYPE_BASE_VAL; char *msg; - if (i < 0 || i > ARRAY_SIZE(siano_msgs)) + if (i < 0 || i >= ARRAY_SIZE(siano_msgs)) return "Unknown msg type"; msg = siano_msgs[i];