]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Fix an overflow case in fdt_offset_ptr() detected by GCC 4.3.
authorJon Loeliger <jdl@freescale.com>
Thu, 25 Sep 2008 16:02:17 +0000 (11:02 -0500)
committerGerald Van Baren <vanbaren@cideas.com>
Thu, 2 Oct 2008 02:01:52 +0000 (22:01 -0400)
Using Gcc 4.3 detected this problem:

    ../dtc/libfdt/fdt.c: In function 'fdt_next_tag':
    ../dtc/libfdt/fdt.c:82: error: assuming signed overflow does not
    occur when assuming that (X + c) < X is always false

To fix the problem, treat the offset as an unsigned int.

The problem report and proposed fix were provided
by Steve Papacharalambous <stevep@freescale.com>.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
include/libfdt.h
libfdt/fdt.c

index 94c35e330c8d7a62a760b9d8774f08d3df1c2db0..5492a535207816765730f366bbec52e600969e40 100644 (file)
 /* Low-level functions (you probably don't need these)                */
 /**********************************************************************/
 
-const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
+const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
 static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
 {
        return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
index 732103b07bd368790ba28ecfe1ea551345aa80a8..a59a518b0e2e1684d976c7e36e37063e8bce2579 100644 (file)
@@ -78,7 +78,7 @@ int fdt_check_header(const void *fdt)
        return 0;
 }
 
-const void *fdt_offset_ptr(const void *fdt, int offset, int len)
+const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 {
        const char *p;