PR25842, Null pointer dereference in nm-new
authorAlan Modra <amodra@gmail.com>
Thu, 16 Apr 2020 22:59:15 +0000 (08:29 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 17 Apr 2020 01:26:01 +0000 (10:56 +0930)
PR 25842
* elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on
NULL nodename.

bfd/ChangeLog
bfd/elf.c

index 7f361d7fb1823762842a2a307680a77709c46594..b9ee79572aa3aa0a2bf3c63215f75c62feab0aa3 100644 (file)
@@ -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
index 3d2eee9ea8b96122b8888a0f08d30c52495bebc0..f3364eeddf2a5db3b8e209e82c76278af574c83b 100644 (file)
--- 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
        {