public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] libbacktrace: don't crash if ELF file has no sections
@ 2020-08-22 21:03 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d9b3c4fc20d9e1f67e4e5eac515584e202b6ed38

commit d9b3c4fc20d9e1f67e4e5eac515584e202b6ed38
Author: Ian Lance Taylor <iant@golang.org>
Date:   Sat May 9 20:34:25 2020 -0700

    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.

Diff:
---
 libbacktrace/ChangeLog | 4 ++++
 libbacktrace/elf.c     | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 13d907011d8..88dee9983d3 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 1216af86fd9..80a00506bd6 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.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 21:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:03 [gcc/devel/autopar_devel] libbacktrace: don't crash if ELF file has no sections Giuliano Belinassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).