aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-09-01 11:20:51 +0100
committerNick Clifton <nickc@redhat.com>2017-09-01 11:20:51 +0100
commit7e8b60085eb3e6f2c41bc0c00c0d759fa7f72780 (patch)
tree5375adc59b856bd69905d8eae6f7c92161150d79
parentf8ad2513754f5a53fecb407cf64fcb586836b60c (diff)
downloadgdb-7e8b60085eb3e6f2c41bc0c00c0d759fa7f72780.zip
gdb-7e8b60085eb3e6f2c41bc0c00c0d759fa7f72780.tar.gz
gdb-7e8b60085eb3e6f2c41bc0c00c0d759fa7f72780.tar.bz2
Prevent an address violation parsing corrupt DWARF information by fixing the test for an overlong debug line info structure.
PR 22059 * dwarf2.c (decode_line_info): Fix test for an overlong line info structure.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/dwarf2.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e0dd88f..8c6e8b1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2017-09-01 Nick Clifton <nickc@redhat.com>
+ PR 22059
+ * dwarf2.c (decode_line_info): Fix test for an overlong line info
+ structure.
+
+2017-09-01 Nick Clifton <nickc@redhat.com>
+
PR 22058
* elf-attrs.c (_bfd_elf_parse_attributes): Ensure that the
attribute buffer is NUL terminated.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 40a187a..856c963 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2096,12 +2096,12 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
offset_size = 8;
}
- if (lh.total_length > stash->dwarf_line_size)
+ if (unit->line_offset + lh.total_length > stash->dwarf_line_size)
{
_bfd_error_handler
/* xgettext: c-format */
- (_("Dwarf Error: Line info data is bigger (%#Lx) than the section (%#Lx)"),
- lh.total_length, stash->dwarf_line_size);
+ (_("Dwarf Error: Line info data is bigger (%#Lx) than the space remaining in the section (%#Lx)"),
+ lh.total_length, stash->dwarf_line_size - unit->line_offset);
bfd_set_error (bfd_error_bad_value);
return NULL;
}