From: Mike Frysinger Date: Fri, 23 Sep 2011 18:36:34 -0400 Subject: [U-Boot] [PATCH 3/4] Make printf and vprintf safe from buffer overruns In-Reply-To: References: <1316799532-20761-1-git-send-email-sjg@chromium.org> <201109231631.56071.vapier@gentoo.org> Message-ID: <201109231836.36793.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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