cmd_mtdparts.c: prevent printbuffer overflows
PATCH v2 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 v1:
- use puts() instead of printf() as suggested by Wolfgang.
common/cmd_mtdparts.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
common/cmd_mtdparts.c +3 -2
@@ -1254,8 +1254,9 @@ 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" ); +puts ("mtdparts: " ); +puts (mtdparts_default ? mtdparts_default :"none" ); +puts ("\n" ); }/**
Signature · 1 line
1.6.3.3
PATCH v2 1/1 cmd_mtdparts.c: prevent printbuffer overflows
Hi Anatolij,
Quoted 18 lines · On Tuesday 23 February 2010 16:18:30 Anatolij Gustschin wrote:
The length of configured
MTDPARTS_DEFAULTstring could be greater than console printbuffer size. Replaceprintf()byputs()to avoid potential buffer overflows.Signed-off-by Anatolij Gustschin <[email protected]>---
Changes since v1:
- useputs()instead ofprintf()as suggested by Wolfgang.common/cmd_mtdparts.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)common/cmd_mtdparts.c +0
-0
common/cmd_mtdparts.c static void list_partitions(void) · line 1259
Quoted 8 lines
common/cmd_mtdparts.c +3
-2@@ -1254,8 +1254,9 @@ 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" ); +puts ("mtdparts: " ); +puts (mtdparts_default ? mtdparts_default :"none" ); +puts ("\n" );
It might make sense to add a comment here, describing why you use these puts() calls instead of one printf(). Otherwise somebody else might trip into this problem again in a later time.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH v2 1/1 cmd_mtdparts.c: prevent printbuffer overflows
Hi Stefan,
Quoted 9 lines · Stefan Roese
common/cmd_mtdparts.c static void list_partitions(void) · line 1259
Quoted 5 lines
common/cmd_mtdparts.c +3
-2-printf ("mtdparts: %s\n" , - mtdparts_default ? mtdparts_default :"none" ); +puts ("mtdparts: " ); +puts (mtdparts_default ? mtdparts_default :"none" ); +puts ("\n" );It might make sense to add a comment here, describing why you use these
puts()calls instead of oneprintf(). Otherwise somebody else might trip into this problem again in a later time.
This makes sense. I'll add a comment in next patch version.
Best regards,
Anatolij