[binutils-gdb] Catch potential integer overflow in readelf when processing corrupt binaries.

Nick Clifton nickc@sourceware.org
Mon Aug 5 09:41:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e17869db99195849826eaaf5d2d0eb2cfdd7a2a7

commit e17869db99195849826eaaf5d2d0eb2cfdd7a2a7
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Aug 5 10:40:35 2019 +0100

    Catch potential integer overflow in readelf when processing corrupt binaries.
    
    	PR 24829
    	* readelf.c (apply_relocations): Catch potential integer overflow
    	whilst checking reloc location against section size.

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

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index f3dc48c..22a7828 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-05  Nick Clifton  <nickc@redhat.com>
+
+	PR 24829
+	* readelf.c (apply_relocations): Catch potential integer overflow
+	whilst checking reloc location against section size.
+
 2019-08-02  Alan Modra  <amodra@gmail.com>
 
 	PR 24871
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b896ad9..e785fde 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13366,7 +13366,7 @@ apply_relocations (Filedata *                 filedata,
 	    }
 
 	  rloc = start + rp->r_offset;
-	  if ((rloc + reloc_size) > end || (rloc < start))
+	  if (rloc >= end || (rloc + reloc_size) > end || (rloc < start))
 	    {
 	      warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
 		    (unsigned long) rp->r_offset,



More information about the Binutils-cvs mailing list