From: Gerlando Falauto Date: Fri, 5 Oct 2012 00:46:10 +0000 (+0000) Subject: env: fix crash using default -f -a X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=7ac80551c447a3637b00bb1e2ad610e8bd13a570;p=u-boot.git env: fix crash using default -f -a 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 Tested-by: Stefano Babic --- diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 8ecc498230..bb1d4ec3e5 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -215,6 +215,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;