lkml.org 
[lkml]   [2010]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: arch/arm/mach-omap2/mux.c: Off by one error
From
Date
On Mon, 2010-02-01 at 13:06 -0800, Tony Lindgren wrote:
> * d binderman <dcb314@hotmail.com> [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?



\
 
 \ /
  Last update: 2010-02-01 22:19    [W:0.036 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site