From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Fri, 05 Oct 2012 13:50:05 +0200 Subject: [U-Boot] [PATCH] env: fix crash using default -f -a In-Reply-To: <1349433970-16689-1-git-send-email-gerlando.falauto@keymile.com> References: <506EB964.4030902@denx.de> <1349433970-16689-1-git-send-email-gerlando.falauto@keymile.com> Message-ID: <506EC96D.2030403@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Signed-off-by: Gerlando Falauto > --- > 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 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 =====================================================================