The length of configured MTDPARTS_DEFAULT string
could be greather than console printbuffer size.
Check the lenght of the string before printing
to prevent U-Boot crashes.

Signed-off-by: Anatolij Gustschin <ag...@denx.de>
---
 common/cmd_mtdparts.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 230e96e..d4cb194 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -1254,6 +1254,14 @@ static void list_partitions(void)
        printf("\ndefaults:\n");
        printf("mtdids  : %s\n",
                mtdids_default ? mtdids_default : "none");
+
+       /* Check to prevent printbuffer overflows */
+       if (mtdparts_default && strlen(mtdparts_default) > CONFIG_SYS_PBSIZE) {
+               puts("Warning: mtdparts too long,"
+                    " please increase CONFIG_SYS_PBSIZE\n");
+               return;
+       }
+
        printf("mtdparts: %s\n",
                mtdparts_default ? mtdparts_default : "none");
 }
-- 
1.6.3.3

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

Reply via email to