diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-05-09 20:34:25 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-05-09 20:34:25 -0700 |
commit | ef6394205d7bcab00dca01182d708ad5a6360a7b (patch) | |
tree | 8eedda9eef3497501933c16c6147e6039d29428c /libbacktrace | |
parent | 4ae915cdbf0d8aec5bf4db9a6b37306e84f99766 (diff) | |
download | gcc-ef6394205d7bcab00dca01182d708ad5a6360a7b.zip gcc-ef6394205d7bcab00dca01182d708ad5a6360a7b.tar.gz gcc-ef6394205d7bcab00dca01182d708ad5a6360a7b.tar.bz2 |
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.
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 4 | ||||
-rw-r--r-- | libbacktrace/elf.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 13d9070..88dee99 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -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 diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 1216af8..80a0050 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -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. */ |