aboutsummaryrefslogtreecommitdiff
path: root/binutils/dwarf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-05-13 22:46:36 +0930
committerAlan Modra <amodra@gmail.com>2021-05-13 22:49:17 +0930
commitb96a1bcb81078d6443666a59d6a91368ac03767f (patch)
tree64089e6159076fbb95a47621e0bb9f117a905965 /binutils/dwarf.c
parentd21f875d6768aa1e5b8e5442c7e60b03307b1949 (diff)
downloadgdb-b96a1bcb81078d6443666a59d6a91368ac03767f.zip
gdb-b96a1bcb81078d6443666a59d6a91368ac03767f.tar.gz
gdb-b96a1bcb81078d6443666a59d6a91368ac03767f.tar.bz2
PR27861, Infinite loop in dwarf.c:7507-7526
PR 27861 * dwarf.c (display_debug_str_offsets): Sanity check dwarf5 header length.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r--binutils/dwarf.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 20bd926..b22d33c 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7487,7 +7487,14 @@ display_debug_str_offsets (struct dwarf_section *section,
}
else
{
- entries_end = curr + length;
+ if (length <= (dwarf_vma) (end - curr))
+ entries_end = curr + length;
+ else
+ {
+ warn (_("Section %s is too small %#lx\n"),
+ section->name, (unsigned long) section->size);
+ entries_end = end;
+ }
int version;
SAFE_BYTE_GET_AND_INC (version, curr, 2, end);