All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Loeliger <jdl-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
To: devicetree-discuss
	<devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>
Cc: Stephen Papacharalambous
	<SteveP-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Subject: [PATCH] Fix an overflow case in fdt_offset_ptr() detected by GCC 4.3.
Date: Thu, 25 Sep 2008 11:02:17 -0500	[thread overview]
Message-ID: <1222358537.25112.7.camel@ld0161-tx32> (raw)


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-KZfg59tc24xl57MIdRCFDg@public.gmane.org>.

Signed-off-by: Jon Loeliger <jdl-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 libfdt/fdt.c    |    2 +-
 libfdt/libfdt.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index 2acaec5..37085c1 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -74,7 +74,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;
 
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 9e4f990..60dd4a1 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -122,7 +122,7 @@
 /* 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);
-- 
1.6.0.2.g2ebc0

             reply	other threads:[~2008-09-25 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-25 16:02 Jon Loeliger [this message]
2008-09-26  1:29 ` [PATCH] Fix an overflow case in fdt_offset_ptr() detected by GCC 4.3 David Gibson
2008-09-29 21:13 ` Jon Loeliger
     [not found]   ` <E1KkQ3b-0000uT-6H-CYoMK+44s/E@public.gmane.org>
2008-09-30  1:15     ` David Gibson
     [not found]       ` <20080930011525.GB6189-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
2008-09-30  1:51         ` Jon Loeliger
     [not found]           ` <E1KkUOE-0001OX-EF-CYoMK+44s/E@public.gmane.org>
2008-09-30  2:39             ` David Gibson
     [not found]               ` <20080930023934.GB8939-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
2008-09-30  8:03                 ` Steve Papacharalambous
2008-09-30 16:28                 ` Scott Wood
     [not found]                   ` <48E253A2.1090702-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2008-10-01  1:19                     ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1222358537.25112.7.camel@ld0161-tx32 \
    --to=jdl-kzfg59tc24xl57midrcfdg@public.gmane.org \
    --cc=SteveP-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.