[U-Boot] [PATCH v2] net: Fix arguments in tftpput command

Simon Glass sjg at chromium.org
Tue Dec 20 03:10:43 CET 2011


The switch to strict_strtoul() was not done correctly - this fixes
the compile error when CONFIG_CMD_TFTPPUT is active.

There appears to very little use of strict_strtoul() in commands, so
it might be easier to switch to simple_strtoul(). If not, we should
decide the best way to use strict_strtoul(). For now I have added a
friendly message which will of course increase code size.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Check return value and print friendly message if incorrect

 common/cmd_net.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index f89a24b..89519fa 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -221,8 +221,11 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 
 #ifdef CONFIG_CMD_TFTPPUT
 	case 4:
-		save_addr = strict_strtoul(argv[1], NULL, 16);
-		save_size = strict_strtoul(argv[2], NULL, 16);
+		if (strict_strtoul(argv[1], 16, &save_addr) < 0 ||
+			strict_strtoul(argv[2], 16, &save_size) < 0) {
+			printf("Invalid address/size\n");
+			return cmd_usage(cmdtp);
+		}
 		copy_filename(BootFile, argv[3], sizeof(BootFile));
 		break;
 #endif
-- 
1.7.3.1



More information about the U-Boot mailing list