mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Fix the error checking for the ubenv command. This moves the check for an
empty ldvar (which amounts to the varname string starting with '=') into the if block that manipulates ldvar, which avoids later referencing ldvar when it was never initialized. Submitted by: Thomas Skibo Pointy hat: ian
This commit is contained in:
parent
4f2f5faa62
commit
b8466276a1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=292888
|
@ -585,6 +585,10 @@ handle_uboot_env_var(enum ubenv_action action, const char * var)
|
|||
*/
|
||||
if (action == UBENV_IMPORT) {
|
||||
len = strcspn(var, "=");
|
||||
if (len == 0) {
|
||||
printf("name cannot start with '=': '%s'\n", var);
|
||||
return;
|
||||
}
|
||||
if (var[len] == 0) {
|
||||
strcpy(ldvar, "uboot.");
|
||||
strncat(ldvar, var, sizeof(ldvar) - 7);
|
||||
|
@ -604,9 +608,11 @@ handle_uboot_env_var(enum ubenv_action action, const char * var)
|
|||
var = &var[6];
|
||||
}
|
||||
|
||||
/* If ldvar is malformed or there's no variable name left, punt. */
|
||||
if (ldvar[0] == 0 || var[0] == 0)
|
||||
/* If there is no variable name left, punt. */
|
||||
if (var[0] == 0) {
|
||||
printf("empty variable name\n");
|
||||
return;
|
||||
}
|
||||
|
||||
val = ub_env_get(var);
|
||||
if (action == UBENV_SHOW) {
|
||||
|
|
Loading…
Reference in a new issue