aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-08-06 19:08:30 +0930
committerAlan Modra <amodra@gmail.com>2021-08-06 23:06:53 +0930
commit856c1545ce00d5c7d9368cdf5cb9dc7181c981e8 (patch)
tree924c8c819c40921942fb87fc0e2dc108fc7edd18 /bfd
parente039f7ed8675ddc9d2aa1e60df49dbc8d2836fc7 (diff)
downloadgdb-856c1545ce00d5c7d9368cdf5cb9dc7181c981e8.zip
gdb-856c1545ce00d5c7d9368cdf5cb9dc7181c981e8.tar.gz
gdb-856c1545ce00d5c7d9368cdf5cb9dc7181c981e8.tar.bz2
bfd_reloc_offset_in_range overflow
This patch is more about the style of bounds checking we ought to use, rather than a real problem. An overflow of "octet + reloc_size" can only happen with huge sections which would certainly cause out of memory errors. * reloc.c (bfd_reloc_offset_in_range): Avoid possible overflow.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/reloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 6d920e1..441ddd8 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -547,7 +547,7 @@ bfd_reloc_offset_in_range (reloc_howto_type *howto,
/* The reloc field must be contained entirely within the section.
Allow zero length fields (marker relocs or NONE relocs where no
relocation will be performed) at the end of the section. */
- return octet <= octet_end && octet + reloc_size <= octet_end;
+ return octet <= octet_end && reloc_size <= octet_end - octet;
}
/* Read and return the section contents at DATA converted to a host