[U-Boot] [PATCH 3/4] Make printf and vprintf safe from buffer overruns
Simon Glass
sjg at chromium.org
Fri Sep 23 22:41:50 CEST 2011
Hi Mike,
On Fri, Sep 23, 2011 at 1:31 PM, Mike Frysinger <vapier at gentoo.org> 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?
Regards,
Simon
More information about the U-Boot
mailing list