Date: Tue, 19 Jan 2016 21:42:19 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r294346 - stable/10/sys/boot/uboot/common Message-ID: <201601192142.u0JLgJ0Z046962@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Tue Jan 19 21:42:19 2016 New Revision: 294346 URL: https://svnweb.freebsd.org/changeset/base/294346 Log: 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. Modified: stable/10/sys/boot/uboot/common/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/uboot/common/main.c ============================================================================== --- stable/10/sys/boot/uboot/common/main.c Tue Jan 19 21:39:21 2016 (r294345) +++ stable/10/sys/boot/uboot/common/main.c Tue Jan 19 21:42:19 2016 (r294346) @@ -585,6 +585,10 @@ handle_uboot_env_var(enum ubenv_action a */ 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 a 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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601192142.u0JLgJ0Z046962>