Fix propnames in kexec/arch/ppc64/fs2dt.c

* Makes sure it is initialised as null terminated
* Make sure it is not overrun when new elements are added

Signed-off-by: Simon Horman <[EMAIL PROTECTED]>

Index: kexec-tools-testing/kexec/arch/ppc64/fs2dt.c
===================================================================
--- kexec-tools-testing.orig/kexec/arch/ppc64/fs2dt.c   2006-12-11 
14:29:49.000000000 +0900
+++ kexec-tools-testing/kexec/arch/ppc64/fs2dt.c        2006-12-11 
14:33:26.000000000 +0900
@@ -58,7 +58,7 @@
 }
 
 static char pathname[MAXPATH], *pathstart;
-static char propnames[NAMESPACE];
+static char propnames[NAMESPACE] = { 0 };
 static unsigned dtstruct[TREEWORDS], *dt;
 static unsigned long long mem_rsrv[2*MEMRESERVE];
 
@@ -114,16 +114,22 @@
  * return the property index for a property name, creating a new one
  * if needed.
  */
-static unsigned propnum(const char *name)
+static int propnum(const char *name)
 {
-       unsigned offset = 0;
+       int offset = 0;
+       size_t len;
+
+       len = strlen(propnames+offset);
 
        while(propnames[offset])
                if (strcmp(name, propnames+offset))
-                       offset += strlen(propnames+offset)+1;
+                       offset += len + 1;
                else
                        return offset;
 
+       if (NAMESPACE - offset < len + 1)
+               return -1;
+
        strcpy(propnames+offset, name);
 
        return offset;

--

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to