summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorSonny Rao <sonnyrao@chromium.org>2011-10-10 09:22:31 +0000
committerWolfgang Denk <wd@denx.de>2011-12-17 23:34:43 +0100
commit068af6f843844319dc4d5c76020d311a69000482 (patch)
tree51afa14204d64abe87a2c38747e497b2b14ef041 /common/console.c
parent71ec92b67c1983a87a8c405d280e2dba1cc0080d (diff)
downloadu-boot-imx-068af6f843844319dc4d5c76020d311a69000482.zip
u-boot-imx-068af6f843844319dc4d5c76020d311a69000482.tar.gz
u-boot-imx-068af6f843844319dc4d5c76020d311a69000482.tar.bz2
Make printf and vprintf safe from buffer overruns
From: Sonny Rao <sonnyrao@chromium.org> utilize the added vscnprintf functions to avoid buffer overruns The implementation is fairly dumb in that it doesn't detect that the buffer is too small, but at least will not cause crashes. Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/common/console.c b/common/console.c
index d34a0f4..1d9fd7f 100644
--- 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, sizeof(printbuffer), fmt, args);
va_end(args);
serial_puts(printbuffer);
@@ -281,7 +281,7 @@ int fprintf(int file, 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, sizeof(printbuffer), fmt, args);
va_end(args);
/* Send to desired file */
@@ -434,7 +434,7 @@ int 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, sizeof(printbuffer), fmt, args);
va_end(args);
/* Print the string */
@@ -455,7 +455,7 @@ int vprintf(const char *fmt, va_list args)
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
- i = vsprintf(printbuffer, fmt, args);
+ i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
/* Print the string */
puts(printbuffer);
@@ -522,7 +522,7 @@ inline void dbg(const char *fmt, ...)
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
- i = vsprintf(printbuffer, fmt, args);
+ i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
va_end(args);
if ((screen + sizeof(screen) - 1 - cursor)