Avoid segfault on invalid directory table
authorPádraig Brady <pbrady@fb.com>
Fri, 24 Mar 2017 15:12:53 +0000 (15:12 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 24 Mar 2017 15:12:53 +0000 (15:12 +0000)
commit568c1b9f503649d19ed1d17e6970f212e6b6317d
tree12bfe74915f7385d4ae89a1404e9e12fcc7ed9c9
parent62785b09987359ede74a98fac11343827f7181af
Avoid segfault on invalid directory table

gdb was segfaulting during backtrace on a binary here, where
fe->dir_index parsed from the DWARF info was seen to access beyond the
provided include_dirs array.

This commit bounds the access to entries actually written to the
array, and was verified to output the backtrace correctly.

gdb/ChangeLog:

* dwarf2read.c (setup_type_unit_groups): Ensure dir_index doesn't
reference beyond the 'lh->include_dirs' array before accessing to
it.
(psymtab_include_file_name): Likewise.
(dwarf_decode_lines_1): Likewise.
(dwarf_decode_lines): Likewise.
(file_file_name): Likewise.
gdb/ChangeLog
gdb/dwarf2read.c