This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 4/4] readelf: Use IN_RANGE macro
- From: Christian Eggers <ceggers at gmx dot de>
- To: binutils at sourceware dot org
- Cc: Christian Eggers <ceggers at gmx dot de>
- Date: Sun, 3 Nov 2019 08:57:43 +0100
- Subject: [PATCH 4/4] readelf: Use IN_RANGE macro
- References: <20191103075743.25467-1-ceggers@gmx.de>
* 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