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_nand.c | |
| parent | bc5fd908d976cfd898e8cbb591e7220ddc8a684a (diff) | |
| download | olio-uboot-2014.01-cd0f4fa1ca2901312ae78bc27d4edc8286fcbf1d.tar.xz olio-uboot-2014.01-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_nand.c')
| -rw-r--r-- | common/env_nand.c | 23 | 
1 files changed, 11 insertions, 12 deletions
| diff --git a/common/env_nand.c b/common/env_nand.c index 8cc2055eb..5b69889c0 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -64,8 +64,6 @@ env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST;  env_t *env_ptr;  #endif /* ENV_IS_EMBEDDED */ -DEFINE_CACHE_ALIGN_BUFFER(char, env_buf, CONFIG_ENV_SIZE); -  DECLARE_GLOBAL_DATA_PTR;  /* @@ -175,7 +173,7 @@ static unsigned char env_flags;  int saveenv(void)  { -	env_t	*env_new = (env_t *)env_buf; +	env_t	env_new;  	ssize_t	len;  	char	*res;  	int	ret = 0; @@ -187,14 +185,14 @@ int saveenv(void)  	if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)  		return 1; -	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->flags	= ++env_flags; /* increase the serial */ +	env_new.crc	= crc32(0, env_new.data, ENV_SIZE); +	env_new.flags	= ++env_flags; /* increase the serial */  	if (gd->env_valid == 1) {  		puts("Erasing redundant NAND...\n"); @@ -203,7 +201,7 @@ int saveenv(void)  			return 1;  		puts("Writing to redundant NAND... "); -		ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *)env_new); +		ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *)&env_new);  	} else {  		puts("Erasing NAND...\n");  		nand_erase_options.offset = CONFIG_ENV_OFFSET; @@ -211,7 +209,7 @@ int saveenv(void)  			return 1;  		puts("Writing to NAND... "); -		ret = writeenv(CONFIG_ENV_OFFSET, (u_char *)env_new); +		ret = writeenv(CONFIG_ENV_OFFSET, (u_char *)&env_new);  	}  	if (ret) {  		puts("FAILED!\n"); @@ -228,7 +226,7 @@ int saveenv(void)  int saveenv(void)  {  	int	ret = 0; -	env_t	*env_new = (env_t *)env_buf; +	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);  	ssize_t	len;  	char	*res;  	nand_erase_options_t nand_erase_options; @@ -240,7 +238,7 @@ int saveenv(void)  	if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)  		return 1; -	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); @@ -406,6 +404,7 @@ void env_relocate_spec(void)  {  #if !defined(ENV_IS_EMBEDDED)  	int ret; +	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);  #if defined(CONFIG_ENV_OFFSET_OOB)  	ret = get_nand_env_oob(&nand_info[0], &nand_env_oob_offset); @@ -421,13 +420,13 @@ void env_relocate_spec(void)  	}  #endif -	ret = readenv(CONFIG_ENV_OFFSET, (u_char *)env_buf); +	ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);  	if (ret) {  		set_default_env("!readenv() failed");  		return;  	} -	env_import(env_buf, 1); +	env_import(buf, 1);  #endif /* ! ENV_IS_EMBEDDED */  }  #endif /* CONFIG_ENV_OFFSET_REDUND */ |