This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PR24785, bfd crashes on empty .PPC.EMB.apuinfo section
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 8 Jul 2019 06:01:41 -0000
- Subject: [binutils-gdb] PR24785, bfd crashes on empty .PPC.EMB.apuinfo section
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=62a47958bd6e3cbd909c2f19cd4669a9670ce4f1
commit 62a47958bd6e3cbd909c2f19cd4669a9670ce4f1
Author: Alan Modra <amodra@gmail.com>
Date: Mon Jul 8 10:06:09 2019 +0930
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.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elf32-ppc.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1e2a3f1..7daec6b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index df813d3..ae03d72 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;