diff options
author | Tom Tromey <tromey@adacore.com> | 2022-12-06 12:07:12 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-04-13 13:58:35 -0600 |
commit | f96328accde1e6302b62aa880675594618079cb3 (patch) | |
tree | 4ed79fe1a3f483cdf92db1dd2d530658cb68f68e /gdb/symfile.h | |
parent | 546c7898dccb204eb56c8ed7c5b707c75de31b53 (diff) | |
download | fsf-binutils-gdb-f96328accde1e6302b62aa880675594618079cb3.zip fsf-binutils-gdb-f96328accde1e6302b62aa880675594618079cb3.tar.gz fsf-binutils-gdb-f96328accde1e6302b62aa880675594618079cb3.tar.bz2 |
Avoid double-free with debuginfod
PR gdb/29257 points out a possible double free when debuginfod is in
use. Aside from some ugly warts in the symbol code (an ongoing
issue), the underlying issue in this particular case is that elfread.c
seems to assume that symfile_bfd_open will return NULL on error,
whereas in reality it throws an exception. As this code isn't
prepared for an exception, bad things result.
This patch fixes the problem by introducing a non-throwing variant of
symfile_bfd_open and using it in the affected places.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29257
Diffstat (limited to 'gdb/symfile.h')
-rw-r--r-- | gdb/symfile.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h index b433e2b..7c800ea 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -276,6 +276,11 @@ extern void set_initial_language (void); extern gdb_bfd_ref_ptr symfile_bfd_open (const char *); +/* Like symfile_bfd_open, but will not throw an exception on error. + Instead, it issues a warning and returns nullptr. */ + +extern gdb_bfd_ref_ptr symfile_bfd_open_no_error (const char *) noexcept; + extern int get_section_index (struct objfile *, const char *); extern int print_symbol_loading_p (int from_tty, int mainline, int full); |