The sanity check covers the previous minimim size, plus that the size
is at least enough for sh_info verneed entries.
Also, since we write all verneed fields or exit with an error, there
isn't any need to zero the memory allocated for verneed entries.
PR 22166
* elf.c (_bfd_elf_slurp_version_tables): Test sh_info on
SHT_GNU_verneed section for sanity. Don't zalloc memory for
verref.
+2017-09-24 Alan Modra <amodra@gmail.com>
+
+ PR 22166
+ * elf.c (_bfd_elf_slurp_version_tables): Test sh_info on
+ SHT_GNU_verneed section for sanity. Don't zalloc memory for
+ verref.
+
2017-09-22 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/22170
hdr = &elf_tdata (abfd)->dynverref_hdr;
- if (hdr->sh_info == 0 || hdr->sh_size < sizeof (Elf_External_Verneed))
+ if (hdr->sh_info == 0
+ || hdr->sh_info > hdr->sh_size / sizeof (Elf_External_Verneed))
{
error_return_bad_verref:
_bfd_error_handler
goto error_return_verref;
elf_tdata (abfd)->verref = (Elf_Internal_Verneed *)
- bfd_zalloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed));
+ bfd_alloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed));
if (elf_tdata (abfd)->verref == NULL)
goto error_return_verref;