summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2015-06-19 22:24:58 +0000
committersobomax <sobomax@FreeBSD.org>2015-06-19 22:24:58 +0000
commit200a3fb3721aaba084023572ebe9d53bff39946d (patch)
tree6ab965899dd0c0e76e6eed76507221cae2a8bcaa /sys/boot
parent84a04be05a97430d664c4924b6ddbc6245035c20 (diff)
downloadFreeBSD-src-200a3fb3721aaba084023572ebe9d53bff39946d.zip
FreeBSD-src-200a3fb3721aaba084023572ebe9d53bff39946d.tar.gz
Provide bug4bug workaround for certain dumbiness of the u-boot's API_env_enum
function, which is expected to set returned env to NULL upon reaching the end of the environment list but fails to do so in certain cases. The respective u-boot code looks like the following (HEAD at the time of this commit): --- api.c --- 496 static int API_env_enum(va_list ap) ... 510 *next = last; 511 512 for (i = 0; env_get_char(i) != '\0'; i = n + 1) { 513 for (n = i; env_get_char(n) != '\0'; ++n) { 514 if (n >= CONFIG_ENV_SIZE) { 515 /* XXX shouldn't we set *next = NULL?? */ 516 return 0; 517 } 518 } ------------- The net result is that any unfortunate user of the loader's ub_env_enum() function hitting this condition would be trapped in the infinite loop, as the main use pattern of ub_env_enum() is basically the following: while ((env = ub_env_enum(env)) != NULL) { DO STUFF } Which would stuck forever with the last element.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/uboot/lib/glue.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c
index d01e33b..32c4df2 100644
--- a/sys/boot/uboot/lib/glue.c
+++ b/sys/boot/uboot/lib/glue.c
@@ -513,7 +513,7 @@ ub_env_enum(const char *last)
if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env))
return (NULL);
- if (env == NULL)
+ if (env == NULL || last == env)
/* no more env. variables to enumerate */
return (NULL);
OpenPOWER on IntegriCloud