From 8d55d10ac0d112c586eaceb92e75bd9b80aadcc4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 17 Apr 2020 08:29:15 +0930 Subject: [PATCH] PR25842, Null pointer dereference in nm-new PR 25842 * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on NULL nodename. --- bfd/ChangeLog | 6 ++++++ bfd/elf.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7f361d7fb18..b9ee79572aa 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-04-17 Alan Modra + + PR 25842 + * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on + NULL nodename. + 2020-04-16 Nick Clifton PR 25803 diff --git a/bfd/elf.c b/bfd/elf.c index 3d2eee9ea8b..f3364eeddf2 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1911,8 +1911,12 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol, { const char *nodename = elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; - version_string = ((base_p || strcmp (symbol->name, nodename)) - ? nodename : ""); + version_string = ""; + if (base_p + || nodename == NULL + || symbol->name == NULL + || strcmp (symbol->name, nodename) != 0) + version_string = nodename; } else { -- 2.30.2