Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754612Ab0BAVRO (ORCPT ); Mon, 1 Feb 2010 16:17:14 -0500 Received: from mail.perches.com ([173.55.12.10]:1721 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753894Ab0BAVRN (ORCPT ); Mon, 1 Feb 2010 16:17:13 -0500 Subject: Re: arch/arm/mach-omap2/mux.c: Off by one error From: Joe Perches To: Tony Lindgren Cc: d binderman , linux-kernel@vger.kernel.org In-Reply-To: <20100201210633.GC22747@atomide.com> References: <20100201210633.GC22747@atomide.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 01 Feb 2010 13:17:10 -0800 Message-ID: <1265059030.25140.349.camel@Joe-Laptop.home> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1334 Lines: 42 On Mon, 2010-02-01 at 13:06 -0800, Tony Lindgren wrote: > * d binderman [100131 04:14]: > > I just ran the sourceforge tool cppcheck over the source code of the > > new Linux kernel 2.6.33-rc6 > > > > It said > > > > [./arm/mach-omap2/mux.c:492]: (error) Buffer access out-of-bounds > > > > The source code is > > > > char mode[14]; > > int i = -1; > > > > sprintf(mode, "OMAP_MUX_MODE%d", val & 0x7); > > 13 characters + 1 digit + 1 zero byte is more than 14 characters. > > Suggest new code > > char mode[15]; > diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c > index 32764be..047aa57 100644 > --- a/arch/arm/mach-omap2/mux.c > +++ b/arch/arm/mach-omap2/mux.c > @@ -486,7 +486,7 @@ int __init omap_mux_init_signal(char *muxname, int val) > static inline void omap_mux_decode(struct seq_file *s, u16 val) > { > char *flags[OMAP_MUX_MAX_NR_FLAGS]; > - char mode[14]; > + char mode[15]; Maybe: char mode[sizeof("OMAP_MUX_MODE") + 1]; or char mode[OMAP_MUX_DEFNAME_LEN]; with the #define moved up a bit? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/