binutils/binutils-2.24-corrupt-elf.2.patch

92 lines
3.1 KiB
Diff

diff -cpr ../binutils-2.24.orig/bfd/elf.c bfd/elf.c
*** ../binutils-2.24.orig/bfd/elf.c 2014-10-28 16:02:16.233549448 +0000
--- bfd/elf.c 2014-10-28 16:02:36.754653055 +0000
*************** bfd_section_from_shdr (bfd *abfd, unsign
*** 1584,1589 ****
--- 1584,1590 ----
const char *name;
bfd_boolean ret = TRUE;
static bfd_boolean * sections_being_created = NULL;
+ static bfd * sections_being_created_abfd = NULL;
static unsigned int nesting = 0;
if (shindex >= elf_numsections (abfd))
*************** bfd_section_from_shdr (bfd *abfd, unsign
*** 1596,1608 ****
loop. Detect this here, by refusing to load a section that we are
already in the process of loading. We only trigger this test if
we have nested at least three sections deep as normal ELF binaries
! can expect to recurse at least once. */
!
if (sections_being_created == NULL)
{
/* FIXME: It would be more efficient to attach this array to the bfd somehow. */
sections_being_created = (bfd_boolean *)
bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean));
}
if (sections_being_created [shindex])
{
--- 1597,1615 ----
loop. Detect this here, by refusing to load a section that we are
already in the process of loading. We only trigger this test if
we have nested at least three sections deep as normal ELF binaries
! can expect to recurse at least once.
!
! FIXME: It would be better if this array was attached to the bfd,
! rather than being held in a static pointer. */
!
! if (sections_being_created_abfd != abfd)
! sections_being_created = NULL;
if (sections_being_created == NULL)
{
/* FIXME: It would be more efficient to attach this array to the bfd somehow. */
sections_being_created = (bfd_boolean *)
bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean));
+ sections_being_created_abfd = abfd;
}
if (sections_being_created [shindex])
{
*************** bfd_section_from_shdr (bfd *abfd, unsign
*** 2106,2112 ****
if (sections_being_created)
sections_being_created [shindex] = FALSE;
if (-- nesting == 0)
! sections_being_created = NULL;
return ret;
}
--- 2113,2122 ----
if (sections_being_created)
sections_being_created [shindex] = FALSE;
if (-- nesting == 0)
! {
! sections_being_created = NULL;
! sections_being_created_abfd = abfd;
! }
return ret;
}
Only in bfd: elf.c.orig
diff -cpr ../binutils-2.24.orig/bfd/peXXigen.c bfd/peXXigen.c
*** ../binutils-2.24.orig/bfd/peXXigen.c 2014-10-28 16:02:16.251549538 +0000
--- bfd/peXXigen.c 2014-10-28 16:02:36.755653060 +0000
*************** pe_print_edata (bfd * abfd, void * vfile
*** 1444,1449 ****
--- 1444,1458 ----
}
}
+ /* PR 17512: Handle corrupt PE binaries. */
+ if (datasize < 36)
+ {
+ fprintf (file,
+ _("\nThere is an export table in %s, but it is too small (%d)\n"),
+ section->name, (int) datasize);
+ return TRUE;
+ }
+
fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
section->name, (unsigned long) addr);
Only in bfd: peXXigen.c.orig