libbacktrace: don't crash if ELF file has no sections

libbacktrace/
	* elf.c (elf_add): Bail early if there are no section headers at all.
This commit is contained in:
Ian Lance Taylor 2020-05-09 20:34:25 -07:00
parent 4ae915cdbf
commit ef6394205d
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2020-05-09 Roland McGrath <mcgrathr@google.com>
* elf.c (elf_add): Bail early if there are no section headers at all.
2020-05-09 Ian Lance Taylor <iant@golang.org>
* elf.c (elf_add): Don't free strtab if an error occurs after

View File

@ -2781,6 +2781,9 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
backtrace_release_view (state, &shdr_view, error_callback, data);
}
if (shnum == 0 || shstrndx == 0)
goto fail;
/* To translate PC to file/line when using DWARF, we need to find
the .debug_info and .debug_line sections. */