Catch potential integer overflow in readelf when processing corrupt binaries.
[external/binutils.git] / binutils / readelf.c
index b896ad9..e785fde 100644 (file)
@@ -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,