[U-Boot] [PATCH] catch wrong load address passed to fatload / ext2load
Wolfgang Denk
wd at denx.de
Thu Jul 10 01:08:28 CEST 2014
Dear Pavel Machek,
In message <20140709204257.GA28671 at amd.pavel.ucw.cz> you wrote:
>
> If filename is passed instead of address to ext2load or fatload,
> u-boot silently accepts that, and uses 0 for load address and default
> filename from environment. That is confusing, display help instead.
>
> Signed-off-by: Pavel Machek <pavel at denx.de>
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 79d432d..ea15c5f 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -276,6 +276,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> unsigned long pos;
> int len_read;
> unsigned long time;
> + char *ep;
>
> if (argc < 2)
> return CMD_RET_USAGE;
> @@ -286,7 +287,9 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
> return 1;
>
> if (argc >= 4) {
> - addr = simple_strtoul(argv[3], NULL, 16);
> + addr = simple_strtoul(argv[3], &ep, 16);
> + if (ep == argv[3] || *ep != '\0')
> + return CMD_RET_USAGE;
What happens in case of filenames that look like numbers, say "0"?
It may be silly to use such, but it should not be impossible to do so.
Viele Grüße,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
One difference between a man and a machine is that a machine is quiet
when well oiled.
More information about the U-Boot
mailing list