From: Wolfgang Denk Date: Sun, 12 Mar 2006 22:27:46 +0000 (+0100) Subject: Fix array overflow with fw_setenv on uninitialised environment X-Git-Tag: LABEL_2006_04_18_1106~7^2~12 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f07217c9e2912af5b2f05d61829f62cc865b481f;p=u-boot Fix array overflow with fw_setenv on uninitialised environment Patch by Murray Jensen, 15 Jul 2005 --- diff --git a/CHANGELOG b/CHANGELOG index 790b391d55..51efb237fb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ Changes since U-Boot 1.1.4: ====================================================================== +* Fix array overflow with fw_setenv on uninitialised environment + Patch by Murray Jensen, 15 Jul 2005 + * Add support for EmbeddedPlanet EP88x boards Patch by Yuli Barcohen, 13 Jul 2005 diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 74c0498d5a..f723b5bca1 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;