aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-07-10 10:07:17 +0930
committerAlan Modra <amodra@gmail.com>2021-07-10 13:29:04 +0930
commitf8dd36465839e5bc60ffc5e894633d430ec55a06 (patch)
tree7b83525498eabe5124132d2ba590a0b5c7e728e2
parent9039747fb4863c13eaf07f84bb28d50660fb8d85 (diff)
downloadgdb-f8dd36465839e5bc60ffc5e894633d430ec55a06.zip
gdb-f8dd36465839e5bc60ffc5e894633d430ec55a06.tar.gz
gdb-f8dd36465839e5bc60ffc5e894633d430ec55a06.tar.bz2
Tidy commit 49910fd88dcd
Pointer range checking is UB if the values compared are outside the underlying array elements (plus one). * dwarf2.c (read_address): Remove accidental commit. (read_ranges): Compare offset rather than pointers.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/dwarf2.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9cbb9f9..4dc3d68 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2021-07-10 Alan Modra <amodra@gmail.com>
+
+ * dwarf2.c (read_address): Remove accidental commit.
+ (read_ranges): Compare offset rather than pointers.
+
2021-07-08 Nick Clifton <nickc@redhat.com>
* po/pt.po: Updated Portuguese translation.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 1247f95..04f56a7 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -909,8 +909,7 @@ read_address (struct comp_unit *unit, bfd_byte **ptr, bfd_byte *buf_end)
if (bfd_get_flavour (unit->abfd) == bfd_target_elf_flavour)
signed_vma = get_elf_backend_data (unit->abfd)->sign_extend_vma;
- if (unit->addr_size > (size_t) (buf_end - buf)
- || (buf > buf_end))
+ if (unit->addr_size > (size_t) (buf_end - buf))
{
*ptr = buf_end;
return 0;
@@ -3094,12 +3093,10 @@ read_ranges (struct comp_unit *unit, struct arange *arange,
return false;
}
- ranges_ptr = unit->file->dwarf_ranges_buffer + offset;
- if (ranges_ptr < unit->file->dwarf_ranges_buffer)
+ if (offset > unit->file->dwarf_ranges_size)
return false;
+ ranges_ptr = unit->file->dwarf_ranges_buffer + offset;
ranges_end = unit->file->dwarf_ranges_buffer + unit->file->dwarf_ranges_size;
- if (ranges_ptr >= ranges_end)
- return false;
for (;;)
{