Skip to contentSkip to conversation

cmd_mtdparts.c: prevent printbuffer overflows

PATCH New Anatolij Gustschin 2 participants 2 messages Feb 23, 2010 – Mar 11, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 cmd_mtdparts.c: prevent printbuffer overflows

The length of configured MTDPARTS_DEFAULT string could be greater than console printbuffer size. Replace printf() by puts() to avoid potential buffer overflows.

---
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(-)
common/cmd_mtdparts.c +8 -2
index b375fea..20fed2a 100644
@@ -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");
 }
 
 /**
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH v3 1/1 cmd_mtdparts.c: prevent printbuffer overflows

Dear Anatolij Gustschin,

Quoted 10 lines · In message <[email protected]> you wrote:

The length of configured MTDPARTS_DEFAULT string could be greater than console printbuffer size. Replace printf() by puts() to avoid potential buffer overflows.

---
Changes since v2:
- add comment explaining the reason for usage of puts().

Quoted 5 lines

Changes since v1:
- use puts() instead of printf() as suggested by Wolfgang.

 common/cmd_mtdparts.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
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: wd at denx.de
In the future, you're going to get computers as prizes  in  breakfast
cereals.  You'll  throw  them out because your house will be littered
with them.                                             - Robert Lucky