public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] env: fix crash using default -f -a
Date: Fri, 05 Oct 2012 13:50:05 +0200	[thread overview]
Message-ID: <506EC96D.2030403@denx.de> (raw)
In-Reply-To: <1349433970-16689-1-git-send-email-gerlando.falauto@keymile.com>

On 05/10/2012 12:46, Gerlando Falauto wrote:
> env default -a -f calls env_check_apply on all existing environment
> variables with a NULL value for "newval" as a way of cleaning up.
> This causes string manipulation functions to crash on most architectures.
> So replace a NULL argument with an empty string.
> 
> Reported-By: Stefano Babic <sbabic@denx.de>
> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
> ---
>  common/cmd_nvedit.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
> index 3474bc6..c38b475 100644
> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
> @@ -213,6 +213,9 @@ int env_check_apply(const char *name, const char *oldval,
>  {
>  	int   console = -1;
>  
> +	/* Default value for NULL to protect string-manipulating functions */
> +	newval = newval ? : "";
> +
>  	/* Check for console redirection */
>  	if (strcmp(name, "stdin") == 0)
>  		console = stdin;
> 

It fixes the issue.

Tested-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  reply	other threads:[~2012-10-05 11:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-04 17:30 [U-Boot] [PATCH v1] env: fix crash using default -f -a Stefano Babic
2012-10-04 21:57 ` Tom Rini
2012-10-05 10:29 ` Gerlando Falauto
2012-10-05 10:41   ` Stefano Babic
2012-10-05 10:46     ` [U-Boot] [PATCH] " Gerlando Falauto
2012-10-05 11:50       ` Stefano Babic [this message]
2012-10-05 22:26       ` Tom Rini
2012-10-05 10:58     ` [U-Boot] [PATCH v1] " Gerlando Falauto
2012-10-05 11:49       ` Stefano Babic

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=506EC96D.2030403@denx.de \
    --to=sbabic@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox