public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Fix an illegal memory access when an accessing a zer0-lengthverdef table.
@ 2023-03-30  9:11 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2023-03-30  9:11 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57

commit c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Mar 30 10:10:09 2023 +0100

    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.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/elf.c     | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cac222cd564..d9fe0d31a8d 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 027d0143735..185028cbd97 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-30  9:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30  9:11 [binutils-gdb] Fix an illegal memory access when an accessing a zer0-lengthverdef table Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).