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

2011-12-17 Thread Wolfgang Denk
Dear Simon Glass,

In message 1320263530-22843-5-git-send-email-...@chromium.org you wrote:
 From: Sonny Rao sonny...@chromium.org
 
 From: Sonny Rao sonny...@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 sonny...@chromium.org
 ---
 Changes in v2:
 - Use sizeof(printbuffer) instead of CONFIG_SYS_PBSIZE
 - Drop patch which changes network code to use snprintf()
 
 Changes in v5:
 - Drop limits.h as it is used in only two places in U-Boot
 
  common/console.c |   10 +-
  1 files changed, 5 insertions(+), 5 deletions(-)

Applied to next branch, thanks.

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: w...@denx.de
There is, however, a strange, musty smell in the air that reminds  me
of something...hmm...yes...I've got it...there's a VMS nearby, or I'm
a Blit.  - Larry Wall in Configure from the perl distribution
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2011-11-02 Thread Simon Glass
From: Sonny Rao sonny...@chromium.org

From: Sonny Rao sonny...@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 sonny...@chromium.org
---
Changes in v2:
- Use sizeof(printbuffer) instead of CONFIG_SYS_PBSIZE
- Drop patch which changes network code to use snprintf()

Changes in v5:
- Drop limits.h as it is used in only two places in U-Boot

 common/console.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/console.c b/common/console.c
index f17875e..1177f7d 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 */
@@ -426,7 +426,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 */
@@ -447,7 +447,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);
@@ -514,7 +514,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)
-- 
1.7.3.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot