Эх сурвалжийг харах

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>
Gerlando Falauto 12 жил өмнө
parent
commit
7ac80551c4

+ 3 - 0
common/cmd_nvedit.c

@@ -215,6 +215,9 @@ int env_check_apply(const char *name, const char *oldval,
 {
 {
 	int   console = -1;
 	int   console = -1;
 
 
+	/* Default value for NULL to protect string-manipulating functions */
+	newval = newval ? : "";
+
 	/* Check for console redirection */
 	/* Check for console redirection */
 	if (strcmp(name, "stdin") == 0)
 	if (strcmp(name, "stdin") == 0)
 		console = stdin;
 		console = stdin;