PR24785, bfd crashes on empty .PPC.EMB.apuinfo section
Alan Modra
amodra@gmail.com
Mon Jul 8 06:01:00 GMT 2019
PR 24785
* elf32-ppc.c (_bfd_elf_ppc_set_arch): Sanity check .PPC.EMB.apuinfo
size before reading first word.
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index df813d36cc..ae03d72241 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -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;
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list