aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-03-30 10:10:09 +0100
committerNick Clifton <nickc@redhat.com>2023-03-30 10:10:09 +0100
commitc22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57 (patch)
tree94e2113ce1bdaa54a4737af04bcc0ea20b13e17c /bfd
parentf2f9bde5cde7ff34ed0a4c4682a211d402aa1086 (diff)
downloadgdb-c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57.zip
gdb-c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57.tar.gz
gdb-c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57.tar.bz2
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
PR 30285 * elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cac222c..d9fe0d3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2023-03-30 Nick Clifton <nickc@redhat.com>
+
+ PR 30285
+ * elf.c (_bfd_elf_slurp_version_tables): Fail if no version
+ definitions are allocated.
+
2023-02-27 Felix Willgerodt <felix.willgerodt@intel.com>
* elf64-x86-64.c (elf_x86_64_grok_psinfo): Check for
diff --git a/bfd/elf.c b/bfd/elf.c
index 027d014..185028c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verdef;
}
+
+ if (amt == 0)
+ goto error_return_verdef;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return_verdef;
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return;
}
+ if (amt == 0)
+ goto error_return;
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;