aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-04-17 08:29:15 +0930
committerAlan Modra <amodra@gmail.com>2020-04-17 10:56:01 +0930
commit8d55d10ac0d112c586eaceb92e75bd9b80aadcc4 (patch)
tree74c0545882d7abc3d8c55495c738926738fac3d2 /bfd
parentca3f923f82a079dcf441419f4a50a50f8b4b33c2 (diff)
downloadgdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.zip
gdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.tar.gz
gdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.tar.bz2
PR25842, Null pointer dereference in nm-new
PR 25842 * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on NULL nodename.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7f361d7..b9ee795 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-17 Alan Modra <amodra@gmail.com>
+
+ PR 25842
+ * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on
+ NULL nodename.
+
2020-04-16 Nick Clifton <nickc@redhat.com>
PR 25803
diff --git a/bfd/elf.c b/bfd/elf.c
index 3d2eee9..f3364ee 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
{