From: Anatolij Gustschin Date: Wed, 24 Feb 2010 00:29:44 +0100 Subject: [U-Boot] [PATCH v3] cmd_mtdparts.c: prevent printbuffer overflows Message-ID: <1266967784-12611-1-git-send-email-agust@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The length of configured MTDPARTS_DEFAULT string could be greater than console printbuffer size. Replace printf() by puts() to avoid potential buffer overflows. Signed-off-by: Anatolij Gustschin --- Changes since v2: - add comment explaining the reason for usage of puts(). Changes since v1: - use puts() instead of printf() as suggested by Wolfgang. common/cmd_mtdparts.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index b375fea..20fed2a 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -1254,8 +1254,14 @@ static void list_partitions(void) printf("\ndefaults:\n"); printf("mtdids : %s\n", mtdids_default ? mtdids_default : "none"); - printf("mtdparts: %s\n", - mtdparts_default ? mtdparts_default : "none"); + /* + * Using printf() here results in printbuffer overflow + * if default mtdparts string is greater than console + * printbuffer. Use puts() to prevent system crashes. + */ + puts("mtdparts: "); + puts(mtdparts_default ? mtdparts_default : "none"); + puts("\n"); } /** -- 1.6.3.3