recovery: check variable returned by uboot_getenv() is not NULL
The use of this function, which is a wrapper over libuboot_get_env(),
requires checking if the returned string is NULL.
Manipulations of such string without checking whether it's NULL may lead
to segfault errors.
This was seen during firmware update on a device that didn't have the
'dualboot' variable set.
Reported-by: Chandrababu Pigilam <chandrababu.pigilam@digi.com>
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
https://onedigi.atlassian.net/browse/DEL-7645
(cherry picked from commit 8a4484bbd6)
This commit is contained in:
parent
225e6cafb5
commit
53759cd29c
|
|
@ -439,7 +439,7 @@ static int parse_nand_partition_info(char **parts, char **encrypted, unsigned ch
|
||||||
|
|
||||||
/* Parse mtdparts for all partition info */
|
/* Parse mtdparts for all partition info */
|
||||||
ret = uboot_getenv("mtdparts", &var);
|
ret = uboot_getenv("mtdparts", &var);
|
||||||
if (ret) {
|
if (ret || !var) {
|
||||||
fprintf(stderr, "Error: getenv 'mtdparts'\n");
|
fprintf(stderr, "Error: getenv 'mtdparts'\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -978,6 +978,10 @@ int is_dualboot_enabled (void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Consider dualboot not enabled if variable doesn't exist */
|
||||||
|
if (!var)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Is dualboot enabled */
|
/* Is dualboot enabled */
|
||||||
if (!strcmp(var, "no"))
|
if (!strcmp(var, "no"))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue