diff options
author | Tom Rini <trini@ti.com> | 2013-04-05 14:55:21 -0400 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2013-04-05 14:55:21 -0400 |
commit | cd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d (patch) | |
tree | 244e08cd2c8702c9c6c5854eece41377716dbd31 /common/env_mmc.c | |
parent | bc5fd908d976cfd898e8cbb591e7220ddc8a684a (diff) | |
download | u-boot-midas-cd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d.tar.gz u-boot-midas-cd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d.tar.bz2 u-boot-midas-cd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d.zip |
Revert "env: fix potential stack overflow in environment functions"
Wolfgang requested this be reverted and Rob agreed after further
discussion. This was a symptom of a larger problem we need to deal
with.
This reverts commit 60d7d5a63189c9f77a190c9965861dc15482c2d0.
Signed-off-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'common/env_mmc.c')
-rw-r--r-- | common/env_mmc.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c index f5680134b2..02bd5aed10 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -40,8 +40,6 @@ env_t *env_ptr = &environment; env_t *env_ptr; #endif /* ENV_IS_EMBEDDED */ -DEFINE_CACHE_ALIGN_BUFFER(char, env_buf, CONFIG_ENV_SIZE); - DECLARE_GLOBAL_DATA_PTR; #if !defined(CONFIG_ENV_OFFSET) @@ -114,7 +112,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size, int saveenv(void) { - env_t *env_new = (env_t *)env_buf; + ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); ssize_t len; char *res; struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); @@ -129,7 +127,7 @@ int saveenv(void) goto fini; } - res = (char *)env_new->data; + res = (char *)&env_new->data; len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL); if (len < 0) { error("Cannot export environment: errno = %d\n", errno); @@ -137,7 +135,7 @@ int saveenv(void) goto fini; } - env_new->crc = crc32(0, env_new->data, ENV_SIZE); + env_new->crc = crc32(0, &env_new->data[0], ENV_SIZE); printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV); if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) { puts("failed\n"); @@ -171,6 +169,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size, void env_relocate_spec(void) { #if !defined(ENV_IS_EMBEDDED) + ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); u32 offset; int ret; @@ -185,12 +184,12 @@ void env_relocate_spec(void) goto fini; } - if (read_env(mmc, CONFIG_ENV_SIZE, offset, env_buf)) { + if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) { ret = 1; goto fini; } - env_import(env_buf, 1); + env_import(buf, 1); ret = 0; fini: |