summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-01-19 21:42:19 +0000
committerian <ian@FreeBSD.org>2016-01-19 21:42:19 +0000
commit73c42f454f020871f99f36350a399d27874a87c5 (patch)
tree445ddf6817580529a80b1086319a29c6b9e80efd /sys/boot
parent3c5bf8f9aed8d68d435bf11215f3153209d0ef17 (diff)
downloadFreeBSD-src-73c42f454f020871f99f36350a399d27874a87c5.zip
FreeBSD-src-73c42f454f020871f99f36350a399d27874a87c5.tar.gz
MFC r292888:
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.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/uboot/common/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c
index bcbf6f1..d860d97 100644
--- a/sys/boot/uboot/common/main.c
+++ b/sys/boot/uboot/common/main.c
@@ -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) {
OpenPOWER on IntegriCloud