changeset 2644:80c8675af39a

Stop RedBoot going into an infinite loop when there is something dodgy in the fconfig area.
author bartv
date Thu, 20 Nov 2008 21:27:26 +0000
parents 5ba0b3e7a0cb
children 298cceea89eb
files packages/redboot/current/ChangeLog packages/redboot/current/src/fconfig.c
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog
+++ b/packages/redboot/current/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-20  Bart Veer  <bartv@ecoscentric.com>
+
+	* src/fconfig.c (flash_lookup_config): add a sanity check to
+	reduce the risk of RedBoot going into an infinite loop.
+
 2008-11-16  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* cdl/redboot.cdl, src/flash.c, src/fconfig.c:
--- a/packages/redboot/current/src/fconfig.c
+++ b/packages/redboot/current/src/fconfig.c
@@ -838,6 +838,11 @@ flash_lookup_config(char *key)
         if (strcmp(key, CONFIG_OBJECT_KEY(dp)) == 0) {
             return dp;
         }
+        // Sanity check to prevent RedBoot going into an infinite loop when
+        // there is something dodgy in the fconfig area.
+        if (len <= 0) {
+            break;
+        }
         dp += len;
     }
 //    diag_printf("Can't find config data for '%s'\n", key);