summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-03-12 23:27:46 +0100
committerWolfgang Denk <wd@pollux.denx.de>2006-03-12 23:27:46 +0100
commitf07217c9e2912af5b2f05d61829f62cc865b481f (patch)
tree8132e67eb12885e588aabdf76b47cee688ed807f /tools
parent84c960ce6dbea55565a7891ff4fe87e08803e9cf (diff)
downloadu-boot-imx-f07217c9e2912af5b2f05d61829f62cc865b481f.zip
u-boot-imx-f07217c9e2912af5b2f05d61829f62cc865b481f.tar.gz
u-boot-imx-f07217c9e2912af5b2f05d61829f62cc865b481f.tar.bz2
Fix array overflow with fw_setenv on uninitialised environment
Patch by Murray Jensen, 15 Jul 2005
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 74c0498..f723b5b 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -614,8 +614,7 @@ static int env_init (void)
if (!crc1_ok) {
fprintf (stderr,
"Warning: Bad CRC, using default environment\n");
- environment.data = default_environment;
- free (addr1);
+ memcpy(environment.data, default_environment, sizeof default_environment);
}
} else {
flag1 = environment.flags;
@@ -652,9 +651,8 @@ static int env_init (void)
} else if (!crc1_ok && !crc2_ok) {
fprintf (stderr,
"Warning: Bad CRC, using default environment\n");
- environment.data = default_environment;
+ memcpy(environment.data, default_environment, sizeof default_environment);
curdev = 0;
- free (addr2);
free (addr1);
} else if (flag1 == active_flag && flag2 == obsolete_flag) {
environment.data = addr1;