PR27861, Infinite loop in dwarf.c:7507-7526

PR 27861
	* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
	header length.
This commit is contained in:
Alan Modra 2021-05-13 22:46:36 +09:30
parent d21f875d67
commit b96a1bcb81
2 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2021-05-13 Alan Modra <amodra@gmail.com>
PR 27861
* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
header length.
2021-05-13 Alan Modra <amodra@gmail.com>
PR 27860

View File

@ -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);