This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/4] readelf: Use IN_RANGE macro


	* 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(-)

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,
--
2.16.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]