]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
authorNick Clifton <nickc@redhat.com>
Thu, 30 Mar 2023 09:10:09 +0000 (10:10 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 30 Mar 2023 09:10:09 +0000 (10:10 +0100)
  PR 30285
  * elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.

bfd/ChangeLog
bfd/elf.c

index cac222cd564dd6f8084cb42b198e3a941ce10c8a..d9fe0d31a8dc3f8edcd3ad5d7c70c94b2a78f2ea 100644 (file)
@@ -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
index 027d01437352555bc4ac0717cb0486c751a7775d..185028cbd97ae0901c4276c8a4787b12bb75875a 100644 (file)
--- 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;