[4/4] readelf: Use IN_RANGE macro

Message ID 20191103075743.25467-5-ceggers@gmx.de
State New
Headers show
Series
  • readelf: Fixes for IN_RANGE
Related show

Commit Message

Christian Eggers Nov. 3, 2019, 7:57 a.m.
* readelf.c (apply_relocations): Use IN_RANGE macro.

Signed-off-by: Christian Eggers <ceggers@gmx.de>

---
 binutils/ChangeLog | 1 +
 binutils/readelf.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

--
2.16.4

Patch

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 0e3e3fc535..7a9a086c0f 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -5,6 +5,7 @@ 
 	whilst checking reloc location against section size.
 	* readelf.c (IN_RANGE): Fix off by one error
 	whilst checking reloc location against section size.
+	* readelf.c (apply_relocations): Use IN_RANGE macro.

 2019-10-20  Palmer Dabbelt  <palmer@sifive.com>

diff --git a/binutils/readelf.c b/binutils/readelf.c
index f426cbb2be..7d8d082900 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13411,7 +13411,7 @@  apply_relocations (Filedata *                 filedata,
 	    }

 	  rloc = start + rp->r_offset;
-	  if (rloc >= end || (rloc + reloc_size) > end || (rloc < start))
+	  if (!IN_RANGE(start, end, rloc, reloc_size))
 	    {
 	      warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
 		    (unsigned long) rp->r_offset,