]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix: Segmentation fault caused by npd in objdump
authorNick Clifton <nickc@redhat.com>
Fri, 29 Sep 2023 14:24:26 +0000 (15:24 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 29 Sep 2023 14:24:26 +0000 (15:24 +0100)
  PR 30906
  * elf.c (_bfd_elf_slurp_version_tables): Test that the verref section header has been initialised before using it.

bfd/ChangeLog
bfd/elf.c

index ed9db240eb5e20d26bdcefc2d3a67ce267bd040c..6c4e3e5295381390f694dc86c282847e0a3a7d74 100644 (file)
@@ -1,3 +1,9 @@
+2023-09-29  Nick Clifton  <nickc@redhat.com>
+
+       PR 30906
+       * elf.c (_bfd_elf_slurp_version_tables): Test that the verref
+       section header has been initialised before using it.
+
 2023-09-28  Nick Clifton  <nickc@redhat.com>
 
        PR 30886
index 2bd236b405aad151fb4bac4e9259f949670ccd5a..d5c570f4b8cc7acd4489e01a2e3aee7f66c4cd58 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9482,7 +9482,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
                  = elf_tdata (abfd)->dt_strtab + iverneed->vn_file;
              else
                iverneed->vn_filename = NULL;
-           }   
+           }
+         else if (hdr == NULL)
+           goto error_return_bad_verref;
          else
            iverneed->vn_filename
              = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
@@ -9525,6 +9527,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
                  else
                    ivernaux->vna_nodename = NULL;
                }
+             else if (hdr == NULL)
+               goto error_return_bad_verref;
              else
                ivernaux->vna_nodename
                  = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
@@ -9555,7 +9559,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
          iverneed->vn_nextref = NULL;
          if (iverneed->vn_next == 0)
            break;
-         if (i + 1 < hdr->sh_info)
+         if (hdr != NULL && (i + 1 < hdr->sh_info))
            iverneed->vn_nextref = iverneed + 1;
 
          if (iverneed->vn_next