Commit 7ac80551c447a3637b00bb1e2ad610e8bd13a570

Authored by Gerlando Falauto
Committed by Tom Rini
1 parent 961c437b6c

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>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

... ... @@ -215,6 +215,9 @@
215 215 {
216 216 int console = -1;
217 217  
  218 + /* Default value for NULL to protect string-manipulating functions */
  219 + newval = newval ? : "";
  220 +
218 221 /* Check for console redirection */
219 222 if (strcmp(name, "stdin") == 0)
220 223 console = stdin;