net: Fix download command parsing
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> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
This commit is contained in:
parent
90665e3d97
commit
2e4970d810
|
@ -154,8 +154,10 @@ static int
|
||||||
netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
|
netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
char *end;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
int size;
|
int size;
|
||||||
|
ulong addr;
|
||||||
|
|
||||||
/* pre-set load_addr */
|
/* pre-set load_addr */
|
||||||
if ((s = getenv("loadaddr")) != NULL) {
|
if ((s = getenv("loadaddr")) != NULL) {
|
||||||
|
@ -166,15 +168,17 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* only one arg - accept two forms:
|
case 2: /*
|
||||||
* just load address, or just boot file name.
|
* Only one arg - accept two forms:
|
||||||
* The latter form must be written "filename" here.
|
* 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 */
|
addr = simple_strtoul(argv[1], &end, 16);
|
||||||
copy_filename (BootFile, argv[1], sizeof(BootFile));
|
if (end == (argv[1] + strlen(argv[1])))
|
||||||
} else { /* load address */
|
load_addr = addr;
|
||||||
load_addr = simple_strtoul(argv[1], NULL, 16);
|
else
|
||||||
}
|
copy_filename(BootFile, argv[1], sizeof(BootFile));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: load_addr = simple_strtoul(argv[1], NULL, 16);
|
case 3: load_addr = simple_strtoul(argv[1], NULL, 16);
|
||||||
|
|
Loading…
Reference in New Issue