aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-09-29 15:24:26 +0100
committerNick Clifton <nickc@redhat.com>2023-09-29 15:24:26 +0100
commita78c3c9717e8fa98b11482f948e71c6d1d9d0e44 (patch)
treeabe1ce0e20f072d66bba8afbd32d132dfb344772
parent68510906a981d6abd31c51f49b2ec7e18db0a338 (diff)
downloadbinutils-a78c3c9717e8fa98b11482f948e71c6d1d9d0e44.zip
binutils-a78c3c9717e8fa98b11482f948e71c6d1d9d0e44.tar.gz
binutils-a78c3c9717e8fa98b11482f948e71c6d1d9d0e44.tar.bz2
Fix: Segmentation fault caused by npd in objdump
PR 30906 * elf.c (_bfd_elf_slurp_version_tables): Test that the verref section header has been initialised before using it.
-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 ed9db24..6c4e3e5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/elf.c b/bfd/elf.c
index 2bd236b..d5c570f 100644
--- 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