[U-Boot] [PATCH] cmd_mtdparts.c: prevent printbuffer overflows

Wolfgang Denk wd at denx.de
Tue Feb 23 15:28:44 CET 2010


Dear Detlev Zundel,

In message <m2ljekyyd5.fsf at ohwell.denx.de> you wrote:
> 
> >  	printf("mtdparts: %s\n",
> >  		mtdparts_default ? mtdparts_default : "none");
> >  }
> 
> If I understand this correctly, then the real problem is the console
> code crashing without a warning, correct?  If so, then please put such a

True.

> warning in the correct place instead of fixing the caller sites.

That's not exactly trivial, if you have a look at the code in
"common/console.c" - the printf code has no way to know the size of
the provided buffer.

OTOH it might make sense to use the (small, preconfigured) buffer only
before relocation, and then, when devices become available, switch to
a reasonably sized malloc()ed buffer - say 4 kB?   But then - this
just shifts the limits...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do you know about being with somebody? Wanting to be? If  I  had  the
whole  universe,  I'd  give it to you, Janice. When I see you, I feel
like I'm hungry all over. Do you know how that feels?
	-- Charlie Evans, "Charlie X", stardate 1535.8


More information about the U-Boot mailing list