]> git.sur5r.net Git - u-boot/commitdiff
Fix array overflow with fw_setenv on uninitialised environment
authorWolfgang Denk <wd@pollux.denx.de>
Sun, 12 Mar 2006 22:27:46 +0000 (23:27 +0100)
committerWolfgang Denk <wd@pollux.denx.de>
Sun, 12 Mar 2006 22:27:46 +0000 (23:27 +0100)
Patch by Murray Jensen, 15 Jul 2005

CHANGELOG
tools/env/fw_env.c

index 790b391d553cd7faedff2b01b44d4b938deb9c1e..51efb237fbd38f51971c4b03460523d4ae2578ca 100644 (file)
--- 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
 
index 74c0498d5a671c415f785b1386d8965585e89405..f723b5bca1d0f53f762fb8b20166e7ec02d81e42 100644 (file)
@@ -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;