All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] catch wrong load address passed to fatload / ext2load
Date: Thu, 10 Jul 2014 01:08:28 +0200	[thread overview]
Message-ID: <20140709230828.4B4163809B0@gemini.denx.de> (raw)
In-Reply-To: <20140709204257.GA28671@amd.pavel.ucw.cz>

Dear Pavel Machek,

In message <20140709204257.GA28671@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@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.

  parent reply	other threads:[~2014-07-09 23:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 20:42 [U-Boot] [PATCH] catch wrong load address passed to fatload / ext2load Pavel Machek
2014-07-09 20:46 ` Pavel Machek
2014-07-09 21:07 ` Marek Vasut
2014-07-09 22:57   ` Pavel Machek
2014-07-09 23:08 ` Wolfgang Denk [this message]
2014-07-09 23:12   ` Pavel Machek
2014-07-22 19:22 ` [U-Boot] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140709230828.4B4163809B0@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.