]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf.c
Fix an illegal memory access when an accessing a zer0-lengthverdef table.
[thirdparty/binutils-gdb.git] / bfd / elf.c
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;