diff --git a/commands/loadenv.c b/commands/loadenv.c index 6469aff..bf01072 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -61,6 +61,10 @@ if (argc - optind < 1) { filename = default_environment_path_get(); + if (!filename) { + printf("Default environment path not set\n"); + return 1; + } } else { /* * /dev/defaultenv use to contain the defaultenvironment. diff --git a/common/environment.c b/common/environment.c index 0edf34b..56a030e 100644 --- a/common/environment.c +++ b/common/environment.c @@ -256,9 +256,12 @@ struct action_data data = {}; void *buf = NULL, *wbuf; struct envfs_entry *env; + const char *defenv_path = default_environment_path_get(); if (!filename) - filename = default_environment_path_get(); + filename = defenv_path; + if (!filename) + return -ENOENT; if (!dirname) dirname = "/env"; @@ -365,7 +368,7 @@ ret = 0; #ifdef CONFIG_NVVAR - if (!strcmp(filename, default_environment_path_get())) + if (defenv_path && !strcmp(filename, defenv_path)) nv_var_set_clean(); #endif out: @@ -558,6 +561,8 @@ if (!filename) filename = default_environment_path_get(); + if (!filename) + return -ENOENT; if (!dir) dir = "/env";