* [U-Boot] [PATCH] net: Fix download command parsing
@ 2008-12-02 18:59 Peter Tyser
2008-12-05 7:10 ` Ben Warren
0 siblings, 1 reply; 2+ messages in thread
From: Peter Tyser @ 2008-12-02 18:59 UTC (permalink / raw)
To: u-boot
When CONFIG_SYS_HUSH_PARSER is defined network download
commands with 1 argument in the format 'tftp "/path/file"'
do not work as expected. The hush command parser strips
the quotes from "/path/file" which causes the network
commands to interpret "/path/file" as an address
instead of the intended filename.
The previous check for a leading quote in netboot_common()
was replaced with a check which ensures only valid
numbers are treated as addresses.
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
common/cmd_net.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/common/cmd_net.c b/common/cmd_net.c
index af691a4..1d297ec 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -154,8 +154,10 @@ static int
netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
{
char *s;
+ char *end;
int rcode = 0;
int size;
+ ulong addr;
/* pre-set load_addr */
if ((s = getenv("loadaddr")) != NULL) {
@@ -166,15 +168,17 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
case 1:
break;
- case 2: /* only one arg - accept two forms:
- * just load address, or just boot file name.
- * The latter form must be written "filename" here.
+ case 2: /*
+ * Only one arg - accept two forms:
+ * Just load address, or just boot file name. The latter
+ * form must be written in a format which can not be
+ * mis-interpreted as a valid number.
*/
- if (argv[1][0] == '"') { /* just boot filename */
- copy_filename (BootFile, argv[1], sizeof(BootFile));
- } else { /* load address */
- load_addr = simple_strtoul(argv[1], NULL, 16);
- }
+ addr = simple_strtoul(argv[1], &end, 16);
+ if (end == (argv[1] + strlen(argv[1])))
+ load_addr = addr;
+ else
+ copy_filename(BootFile, argv[1], sizeof(BootFile));
break;
case 3: load_addr = simple_strtoul(argv[1], NULL, 16);
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] net: Fix download command parsing
2008-12-02 18:59 [U-Boot] [PATCH] net: Fix download command parsing Peter Tyser
@ 2008-12-05 7:10 ` Ben Warren
0 siblings, 0 replies; 2+ messages in thread
From: Ben Warren @ 2008-12-05 7:10 UTC (permalink / raw)
To: u-boot
Hi Peter,
Peter Tyser wrote:
> When CONFIG_SYS_HUSH_PARSER is defined network download
> commands with 1 argument in the format 'tftp "/path/file"'
> do not work as expected. The hush command parser strips
> the quotes from "/path/file" which causes the network
> commands to interpret "/path/file" as an address
> instead of the intended filename.
>
> The previous check for a leading quote in netboot_common()
> was replaced with a check which ensures only valid
> numbers are treated as addresses.
>
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
Applied to net repo.
thanks,
Ben
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-05 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-02 18:59 [U-Boot] [PATCH] net: Fix download command parsing Peter Tyser
2008-12-05 7:10 ` Ben Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox