[U-Boot] [PATCH 3/4] Make printf and vprintf safe from buffer overruns

Mike Frysinger vapier at gentoo.org
Sat Sep 24 00:36:34 CEST 2011


On Friday, September 23, 2011 16:41:50 Simon Glass wrote:
> On Fri, Sep 23, 2011 at 1:31 PM, Mike Frysinger wrote:
> > On Friday, September 23, 2011 13:38:51 Simon Glass wrote:
> >> --- a/common/console.c
> >> +++ b/common/console.c
> >> @@ -212,7 +212,7 @@ int serial_printf(const char *fmt, ...)
> >>       /* For this to work, printbuffer must be larger than
> >>        * anything we ever want to print.
> >>        */
> >> -     i = vsprintf(printbuffer, fmt, args);
> >> +     i = vscnprintf(printbuffer, CONFIG_SYS_PBSIZE, fmt, args);
> > 
> > i think sizeof(printbuffer) would be better.  same goes for all the other
> > changes here.
> > -mike
> 
> Yes, indeed. Could we go as far as removing CONFIG_SYS_PBSIZE, and
> just use a standard value?

in the context of I/O funcs, CONFIG_SYS_PBSIZE is the current standard
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110923/342d5445/attachment.pgp 


More information about the U-Boot mailing list