From: Petr Hodina <[email protected]> As dfu_alt_info is read via env_get() it needs to expand the ${var} references using cli_simple_process_macros.
Signed-off-by: Petr Hodina <[email protected]> --- drivers/dfu/dfu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 90d8b45ce8a..fa074db242c 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -6,6 +6,7 @@ * author: Lukasz Majewski <[email protected]> */ +#include <cli.h> #include <env.h> #include <errno.h> #include <log.h> @@ -178,7 +179,20 @@ int dfu_init_env_entities(char *interface, char *devstr) return -EINVAL; } - env_bkp = strdup(str_env); + /* + * Expand the dfu_alt_info here as it's read via env_get() which + * does not expand references the way hush does for a command line + */ + env_bkp = malloc(strlen(str_env) * 2 + 1); + if (!env_bkp) + return -ENOMEM; + + if (cli_simple_process_macros(str_env, env_bkp, + strlen(str_env) * 2 + 1)) { + pr_err("\"dfu_alt_info\" expansion ran out of space!\n"); + free(env_bkp); + return -ENOSPC; + } if (!interface && !devstr) ret = dfu_config_interfaces(env_bkp); else -- 2.55.0
