PR24785, bfd crashes on empty .PPC.EMB.apuinfo section

PR 24785
	* elf32-ppc.c (_bfd_elf_ppc_set_arch): Sanity check .PPC.EMB.apuinfo
	size before reading first word.
This commit is contained in:
Alan Modra 2019-07-08 10:06:09 +09:30
parent 3836e1d1ab
commit 62a47958bd
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2019-07-08 Alan Modra <amodra@gmail.com>
PR 24785
* elf32-ppc.c (_bfd_elf_ppc_set_arch): Sanity check .PPC.EMB.apuinfo
size before reading first word.
2019-07-02 Nick Clifton <nickc@redhat.com>
PR 24717

View File

@ -1077,7 +1077,9 @@ _bfd_elf_ppc_set_arch (bfd *abfd)
if (mach == 0)
{
s = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME);
if (s != NULL && bfd_malloc_and_get_section (abfd, s, &contents))
if (s != NULL
&& s->size >= 24
&& bfd_malloc_and_get_section (abfd, s, &contents))
{
unsigned int apuinfo_size = bfd_get_32 (abfd, contents + 4);
unsigned int i;