All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vincent Stehlé" <vincent.stehle@arm.com>
To: Marek Vasut <marek.vasut+renesas@mailbox.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Patrick Delaunay <patrick.delaunay@st.com>,
	Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH] cmd: nvedit: Validate argument count before use
Date: Thu, 18 Dec 2025 09:21:07 +0100	[thread overview]
Message-ID: <aUO5c2lv2Au1B1Qt@debian> (raw)
In-Reply-To: <20251217195811.754518-1-marek.vasut+renesas@mailbox.org>

On Wed, Dec 17, 2025 at 08:57:38PM +0100, Marek Vasut wrote:
> Avoid NULL pointer dereference in case 'env select' is invoked
> without parameters, check the arg count and make sure it is at
> least 2, otherwise print usage.
> 
> The crash is easy to trigger e.g. in sandbox:
> $ ./u-boot -Tc "env select"

Thanks Marek.

I confirm this patch does indeed fix the crash on sandbox.
The behaviour remains the same when selecting "nowhere".
Feel free to add (or not):

  Tested-by: Vincent Stehlé <vincent.stehle@arm.com>

Best regards,
Vincent.

> 
> Fixes: a97d22ebba23 ("cmd: env: add env select command")
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Vincent Stehlé <vincent.stehle@arm.com>
> Cc: u-boot@lists.denx.de
> ---
>  cmd/nvedit.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 11c3cea882b..636bddee1be 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -499,6 +499,9 @@ static int do_env_load(struct cmd_tbl *cmdtp, int flag, int argc,
>  static int do_env_select(struct cmd_tbl *cmdtp, int flag, int argc,
>  			 char *const argv[])
>  {
> +	if (argc < 2)
> +		return CMD_RET_USAGE;
> +
>  	return env_select(argv[1]) ? 1 : 0;
>  }
>  #endif
> -- 
> 2.51.0
> 

  reply	other threads:[~2025-12-18  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 19:57 [PATCH] cmd: nvedit: Validate argument count before use Marek Vasut
2025-12-18  8:21 ` Vincent Stehlé [this message]
2025-12-18  9:30 ` Ilias Apalodimas
2025-12-18 19:51 ` 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=aUO5c2lv2Au1B1Qt@debian \
    --to=vincent.stehle@arm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=patrick.delaunay@st.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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.