aboutsummaryrefslogtreecommitdiff
path: root/common/env_onenand.c
diff options
context:
space:
mode:
authorTom Rini2013-04-05 14:55:21 -0400
committerTom Rini2013-04-05 14:55:21 -0400
commitcd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d (patch)
tree244e08cd2c8702c9c6c5854eece41377716dbd31 /common/env_onenand.c
parentbc5fd908d976cfd898e8cbb591e7220ddc8a684a (diff)
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_onenand.c')
-rw-r--r--common/env_onenand.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 6fd5613eebe..faa903d2f02 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -42,8 +42,6 @@ char *env_name_spec = "OneNAND";
#define ONENAND_MAX_ENV_SIZE CONFIG_ENV_SIZE
#define ONENAND_ENV_SIZE(mtd) (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
-static char env_buf[CONFIG_ENV_SIZE];
-
DECLARE_GLOBAL_DATA_PTR;
void env_relocate_spec(void)
@@ -58,7 +56,8 @@ void env_relocate_spec(void)
char *buf = (char *)&environment;
#else
loff_t env_addr = CONFIG_ENV_ADDR;
- char *buf = env_buf;
+ char onenand_env[ONENAND_MAX_ENV_SIZE];
+ char *buf = (char *)&onenand_env[0];
#endif /* ENV_IS_EMBEDDED */
#ifndef ENV_IS_EMBEDDED
@@ -82,7 +81,7 @@ void env_relocate_spec(void)
int saveenv(void)
{
- env_t *env_new = env_buf;
+ env_t env_new;
ssize_t len;
char *res;
struct mtd_info *mtd = &onenand_mtd;
@@ -95,13 +94,13 @@ int saveenv(void)
.callback = NULL,
};
- 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);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
instr.len = CONFIG_ENV_SIZE;
#ifdef CONFIG_ENV_ADDR_FLEX
@@ -120,7 +119,7 @@ int saveenv(void)
}
if (mtd->write(mtd, env_addr, ONENAND_MAX_ENV_SIZE, &retlen,
- (u_char *)env_new)) {
+ (u_char *)&env_new)) {
printf("OneNAND: write failed at 0x%llx\n", instr.addr);
return 2;
}