summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGerlando Falauto <gerlando.falauto@keymile.com>2012-10-05 00:46:10 +0000
committerTom Rini <trini@ti.com>2012-10-05 11:07:42 -0700
commit7ac80551c447a3637b00bb1e2ad610e8bd13a570 (patch)
tree4c0d152e5afa8eb5764b2ae86d107dcc2f4aaa0e /common
parent961c437b6cd68375d66c1f0cac9ade63115c0750 (diff)
downloadu-boot-imx-7ac80551c447a3637b00bb1e2ad610e8bd13a570.zip
u-boot-imx-7ac80551c447a3637b00bb1e2ad610e8bd13a570.tar.gz
u-boot-imx-7ac80551c447a3637b00bb1e2ad610e8bd13a570.tar.bz2
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 <sbabic@denx.de> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Tested-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_nvedit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 8ecc498..bb1d4ec 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;