mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-18 22:54:00 +00:00
Merge branch 'master' of https://github.com/archlinuxarm/PKGBUILDs
This commit is contained in:
commit
9581fc6c4a
11 changed files with 1755 additions and 3 deletions
|
@ -11,7 +11,7 @@ noautobuild=1
|
|||
|
||||
pkgname=binutils
|
||||
pkgver=2.24
|
||||
pkgrel=7
|
||||
pkgrel=8
|
||||
pkgdesc="A set of programs to assemble and manipulate binary and object files"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://www.gnu.org/software/binutils/"
|
||||
|
@ -24,12 +24,30 @@ install=binutils.install
|
|||
source=(ftp://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.bz2{,.sig}
|
||||
binutils-2.24-lto-testsuite.patch
|
||||
binutils-2.24-gold-testsuite-plugin.patch
|
||||
binutils-2.24-shared-pie.patch)
|
||||
binutils-2.24-shared-pie.patch
|
||||
binutils-2.24-CVE-2014-8484.patch
|
||||
binutils-2.24-CVE-2014-8485.patch
|
||||
binutils-2.24-CVE-2014-8501.patch
|
||||
binutils-2.24-CVE-2014-8502.patch
|
||||
binutils-2.24-CVE-2014-8503.patch
|
||||
binutils-2.24-CVE-2014-8504.patch
|
||||
binutils-2.24-CVE-2014-8737.patch
|
||||
binutils-2.24-CVE-2014-8738.patch
|
||||
binutils-2.24-strings-all-default.patch)
|
||||
md5sums=('e0f71a7b2ddab0f8612336ac81d9636b'
|
||||
'SKIP'
|
||||
'e68a1f221545f082baa5bd417cd077af'
|
||||
'e46bbb03abaa5db58c12247644dc4857'
|
||||
'ec59461c4febab9cfe1c1ef33326bc50')
|
||||
'ec59461c4febab9cfe1c1ef33326bc50'
|
||||
'125d8ce675ced84814d5f068106dbaa3'
|
||||
'6923e5279a84cb7134b07e2cf6686434'
|
||||
'4c590dc70829d8f4fc190f0fe7e3add8'
|
||||
'64efddd24d5628437cc457b468df8de3'
|
||||
'70540e2c6418a54ad88ab9c6b988d075'
|
||||
'acce1f1d28db6bdb84b430a05f331366'
|
||||
'12fb3e860203a06b5d1f4b023c06dcec'
|
||||
'd35b0ccb79d565757821b3e0206f3873'
|
||||
'99445d528110543d88b59a1ec7677592')
|
||||
|
||||
prepare() {
|
||||
cd ${srcdir}/binutils-${pkgver}
|
||||
|
@ -46,6 +64,33 @@ prepare() {
|
|||
# fix issues with -static -fPIE -pie - commit 4199e3b8
|
||||
patch -p1 -i $srcdir/binutils-2.24-shared-pie.patch
|
||||
|
||||
# CVE-2014-8484 - backport of commit bd25671c
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8484.patch
|
||||
|
||||
# CVE-2014-8485 - commit 493a3386
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8485.patch
|
||||
|
||||
# CVE-2014-8501 - commit 7e1e1988
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8501.patch
|
||||
|
||||
# CVE-2014-8502 - commits bf67003b and 5a4b0ccc
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8502.patch
|
||||
|
||||
# CVE-2014-8503 - commit 0102ea8c
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8503.patch
|
||||
|
||||
# CVE-2014-8504 - commit 708d7d0d
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8504.patch
|
||||
|
||||
# CVE-2014-8737 - commit dd9b91de
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8737.patch
|
||||
|
||||
# CVE-2014-8738 - commit bb0d8671
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8738.patch
|
||||
|
||||
# strings -a default - commit 7fac9594 (fedora backport)
|
||||
patch -p0 -i $srcdir/binutils-2.24-strings-all-default.patch
|
||||
|
||||
mkdir ${srcdir}/binutils-build
|
||||
}
|
||||
|
||||
|
|
31
core/binutils/binutils-2.24-CVE-2014-8484.patch
Normal file
31
core/binutils/binutils-2.24-CVE-2014-8484.patch
Normal file
|
@ -0,0 +1,31 @@
|
|||
--- binutils-2.24/bfd/srec.c 2013-11-04 16:33:37.000000000 +0100
|
||||
+++ binutils-2.24-1/bfd/srec.c 2014-10-24 21:46:38.973046641 +0200
|
||||
@@ -455,7 +455,7 @@
|
||||
{
|
||||
file_ptr pos;
|
||||
char hdr[3];
|
||||
- unsigned int bytes;
|
||||
+ unsigned int bytes, min_bytes;
|
||||
bfd_vma address;
|
||||
bfd_byte *data;
|
||||
unsigned char check_sum;
|
||||
@@ -478,6 +478,19 @@
|
||||
}
|
||||
|
||||
check_sum = bytes = HEX (hdr + 1);
|
||||
+ min_bytes = 3;
|
||||
+ if (hdr[0] == '2' || hdr[0] == '8')
|
||||
+ min_bytes = 4;
|
||||
+ else if (hdr[0] == '3' || hdr[0] == '7')
|
||||
+ min_bytes = 5;
|
||||
+ if (bytes < min_bytes)
|
||||
+ {
|
||||
+ (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"),
|
||||
+ abfd, lineno, bytes);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ goto error_return;
|
||||
+ }
|
||||
+
|
||||
if (bytes * 2 > bufsize)
|
||||
{
|
||||
if (buf != NULL)
|
70
core/binutils/binutils-2.24-CVE-2014-8485.patch
Normal file
70
core/binutils/binutils-2.24-CVE-2014-8485.patch
Normal file
|
@ -0,0 +1,70 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c884d1d..c8ac826 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -608,9 +608,10 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
if (shdr->contents == NULL)
|
||||
{
|
||||
_bfd_error_handler
|
||||
- (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
+ (_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
- return FALSE;
|
||||
+ -- num_group;
|
||||
+ continue;
|
||||
}
|
||||
|
||||
memset (shdr->contents, 0, amt);
|
||||
@@ -618,8 +619,17 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0
|
||||
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd)
|
||||
!= shdr->sh_size))
|
||||
- return FALSE;
|
||||
-
|
||||
+ {
|
||||
+ _bfd_error_handler
|
||||
+ (_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ -- num_group;
|
||||
+ /* PR 17510: If the group contents are even partially
|
||||
+ corrupt, do not allow any of the contents to be used. */
|
||||
+ memset (shdr->contents, 0, amt);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
/* Translate raw contents, a flag word followed by an
|
||||
array of elf section indices all in target byte order,
|
||||
to the flag word followed by an array of elf section
|
||||
@@ -651,6 +661,21 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ /* PR 17510: Corrupt binaries might contain invalid groups. */
|
||||
+ if (num_group != (unsigned) elf_tdata (abfd)->num_group)
|
||||
+ {
|
||||
+ elf_tdata (abfd)->num_group = num_group;
|
||||
+
|
||||
+ /* If all groups are invalid then fail. */
|
||||
+ if (num_group == 0)
|
||||
+ {
|
||||
+ elf_tdata (abfd)->group_sect_ptr = NULL;
|
||||
+ elf_tdata (abfd)->num_group = num_group = -1;
|
||||
+ (*_bfd_error_handler) (_("%B: no valid group sections found"), abfd);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,6 +741,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%B: no group info for section %A"),
|
||||
abfd, newsect);
|
||||
+ return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
--
|
||||
1.7.1
|
||||
|
26
core/binutils/binutils-2.24-CVE-2014-8501.patch
Normal file
26
core/binutils/binutils-2.24-CVE-2014-8501.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 2fb631c..987be40 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -504,6 +504,18 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
|
||||
{
|
||||
int idx;
|
||||
|
||||
+ /* PR 17512: Corrupt PE binaries can cause seg-faults. */
|
||||
+ if (a->NumberOfRvaAndSizes > 16)
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: aout header specifies an invalid number of data-directory entries: %d"),
|
||||
+ abfd, a->NumberOfRvaAndSizes);
|
||||
+ /* Paranoia: If the number is corrupt, then assume that the
|
||||
+ actual entries themselves might be corrupt as well. */
|
||||
+ a->NumberOfRvaAndSizes = 0;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
|
||||
{
|
||||
/* If data directory is empty, rva also should be 0. */
|
||||
--
|
||||
1.7.1
|
||||
|
481
core/binutils/binutils-2.24-CVE-2014-8502-pre.patch
Normal file
481
core/binutils/binutils-2.24-CVE-2014-8502-pre.patch
Normal file
|
@ -0,0 +1,481 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c8ac826..3fcf2d8 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1578,38 +1578,67 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
Elf_Internal_Ehdr *ehdr;
|
||||
const struct elf_backend_data *bed;
|
||||
const char *name;
|
||||
+ bfd_boolean ret = TRUE;
|
||||
+ static bfd_boolean * sections_being_created = NULL;
|
||||
+ static unsigned int nesting = 0;
|
||||
|
||||
if (shindex >= elf_numsections (abfd))
|
||||
return FALSE;
|
||||
|
||||
+ if (++ nesting > 3)
|
||||
+ {
|
||||
+ /* PR17512: A corrupt ELF binary might contain a recursive group of
|
||||
+ sections, each the string indicies pointing to the next in the
|
||||
+ 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])
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: warning: loop in section dependencies detected"), abfd);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ sections_being_created [shindex] = TRUE;
|
||||
+ }
|
||||
+
|
||||
hdr = elf_elfsections (abfd)[shindex];
|
||||
ehdr = elf_elfheader (abfd);
|
||||
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx,
|
||||
hdr->sh_name);
|
||||
if (name == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
bed = get_elf_backend_data (abfd);
|
||||
switch (hdr->sh_type)
|
||||
{
|
||||
case SHT_NULL:
|
||||
/* Inactive section. Throw it away. */
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_PROGBITS: /* Normal section with contents. */
|
||||
- case SHT_NOBITS: /* .bss section. */
|
||||
- case SHT_HASH: /* .hash section. */
|
||||
- case SHT_NOTE: /* .note section. */
|
||||
+ case SHT_PROGBITS: /* Normal section with contents. */
|
||||
+ case SHT_NOBITS: /* .bss section. */
|
||||
+ case SHT_HASH: /* .hash section. */
|
||||
+ case SHT_NOTE: /* .note section. */
|
||||
case SHT_INIT_ARRAY: /* .init_array section. */
|
||||
case SHT_FINI_ARRAY: /* .fini_array section. */
|
||||
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
|
||||
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
|
||||
case SHT_GNU_HASH: /* .gnu.hash section. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_DYNAMIC: /* Dynamic linking information. */
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_link > elf_numsections (abfd))
|
||||
{
|
||||
/* PR 10478: Accept Solaris binaries with a sh_link
|
||||
@@ -1623,11 +1652,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
/* Otherwise fall through. */
|
||||
default:
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
}
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
|
||||
{
|
||||
Elf_Internal_Shdr *dynsymhdr;
|
||||
@@ -1656,24 +1685,26 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB: /* A symbol table */
|
||||
+ case SHT_SYMTAB: /* A symbol table. */
|
||||
if (elf_onesymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
/* Some assemblers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_onesymtab (abfd) == 0);
|
||||
elf_onesymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_hdr = *hdr;
|
||||
@@ -1690,7 +1721,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
&& (abfd->flags & DYNAMIC) != 0
|
||||
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
|
||||
can't read symbols without that section loaded as well. It
|
||||
@@ -1716,26 +1747,29 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
}
|
||||
if (i != shindex)
|
||||
- return bfd_section_from_shdr (abfd, i);
|
||||
+ ret = bfd_section_from_shdr (abfd, i);
|
||||
}
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_DYNSYM: /* A dynamic symbol table */
|
||||
+ case SHT_DYNSYM: /* A dynamic symbol table. */
|
||||
if (elf_dynsymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
/* Some linkers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_dynsymtab (abfd) == 0);
|
||||
elf_dynsymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynsymtab_hdr = *hdr;
|
||||
@@ -1744,34 +1778,38 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|
||||
/* Besides being a symbol table, we also treat this as a regular
|
||||
section, so that objcopy can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */
|
||||
+ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */
|
||||
if (elf_symtab_shndx (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
|
||||
elf_symtab_shndx (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_STRTAB: /* A string table */
|
||||
+ case SHT_STRTAB: /* A string table. */
|
||||
if (hdr->bfd_section != NULL)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
+
|
||||
if (ehdr->e_shstrndx == shindex)
|
||||
{
|
||||
elf_tdata (abfd)->shstrtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
symtab_strtab:
|
||||
elf_tdata (abfd)->strtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
dynsymtab_strtab:
|
||||
@@ -1780,8 +1818,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
elf_elfsections (abfd)[shindex] = hdr;
|
||||
/* We also treat this as a regular section, so that objcopy
|
||||
can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* If the string table isn't one of the above, then treat it as a
|
||||
@@ -1799,9 +1838,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
{
|
||||
/* Prevent endless recursion on broken objects. */
|
||||
if (i == shindex)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (! bfd_section_from_shdr (abfd, i))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (elf_onesymtab (abfd) == i)
|
||||
goto symtab_strtab;
|
||||
if (elf_dynsymtab (abfd) == i)
|
||||
@@ -1809,7 +1848,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
@@ -1824,7 +1864,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (hdr->sh_entsize
|
||||
!= (bfd_size_type) (hdr->sh_type == SHT_REL
|
||||
? bed->s->sizeof_rel : bed->s->sizeof_rela))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Check for a bogus link to avoid crashing. */
|
||||
if (hdr->sh_link >= num_sec)
|
||||
@@ -1832,8 +1872,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
((*_bfd_error_handler)
|
||||
(_("%B: invalid link %lu for reloc section %s (index %u)"),
|
||||
abfd, hdr->sh_link, name, shindex));
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* For some incomprehensible reason Oracle distributes
|
||||
@@ -1874,7 +1915,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|
||||
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
|
||||
&& ! bfd_section_from_shdr (abfd, hdr->sh_link))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* If this reloc section does not use the main symbol table we
|
||||
don't treat it as a reloc section. BFD can't adequately
|
||||
@@ -1889,14 +1930,18 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_info >= num_sec
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
|
||||
if (! bfd_section_from_shdr (abfd, hdr->sh_info))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
|
||||
if (target_sect == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
esdt = elf_section_data (target_sect);
|
||||
if (hdr->sh_type == SHT_RELA)
|
||||
@@ -1908,7 +1953,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
amt = sizeof (*hdr2);
|
||||
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
|
||||
if (hdr2 == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
*hdr2 = *hdr;
|
||||
*p_hdr = hdr2;
|
||||
elf_elfsections (abfd)[shindex] = hdr2;
|
||||
@@ -1924,34 +1969,40 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
target_sect->use_rela_p = 1;
|
||||
}
|
||||
abfd->flags |= HAS_RELOC;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
case SHT_GNU_verdef:
|
||||
elf_dynverdef (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverdef_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_versym:
|
||||
if (hdr->sh_entsize != sizeof (Elf_External_Versym))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
elf_dynversym (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynversym_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_verneed:
|
||||
elf_dynverref (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverref_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_SHLIB:
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
case SHT_GROUP:
|
||||
if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->contents != NULL)
|
||||
{
|
||||
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
|
||||
@@ -1977,7 +2028,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
default:
|
||||
/* Possibly an attributes section. */
|
||||
@@ -1985,14 +2036,14 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_type == bed->obj_attrs_section_type)
|
||||
{
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
_bfd_elf_parse_attributes (abfd, hdr);
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* Check for any processor-specific section types. */
|
||||
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
|
||||
{
|
||||
@@ -2004,9 +2055,12 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"specific section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Allow sections reserved for applications. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ /* Allow sections reserved for applications. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else if (hdr->sh_type >= SHT_LOPROC
|
||||
&& hdr->sh_type <= SHT_HIPROC)
|
||||
@@ -2027,8 +2081,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"`%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Otherwise it should be processed. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ {
|
||||
+ /* Otherwise it should be processed. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
/* FIXME: We should handle this section. */
|
||||
@@ -2036,10 +2093,17 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
(_("%B: don't know how to handle section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
- return TRUE;
|
||||
+ fail:
|
||||
+ ret = FALSE;
|
||||
+ success:
|
||||
+ if (sections_being_created)
|
||||
+ sections_being_created [shindex] = FALSE;
|
||||
+ if (-- nesting == 0)
|
||||
+ sections_being_created = NULL;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/* Return the local symbol specified by ABFD, R_SYMNDX. */
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 987be40..c7d6067 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1705,7 +1705,12 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
_("\nExport Address Table -- Ordinal Base %ld\n"),
|
||||
edt.base);
|
||||
|
||||
- for (i = 0; i < edt.num_functions; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.eat_addr,
|
||||
+ (long) edt.num_functions);
|
||||
+ else for (i = 0; i < edt.num_functions; ++i)
|
||||
{
|
||||
bfd_vma eat_member = bfd_get_32 (abfd,
|
||||
data + edt.eat_addr + (i * 4) - adj);
|
||||
@@ -1741,7 +1746,16 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
fprintf (file,
|
||||
_("\n[Ordinal/Name Pointer] Table\n"));
|
||||
|
||||
- for (i = 0; i < edt.num_names; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.npt_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.ot_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else for (i = 0; i < edt.num_names; ++i)
|
||||
{
|
||||
bfd_vma name_ptr = bfd_get_32 (abfd,
|
||||
data +
|
||||
--
|
||||
1.7.1
|
||||
|
547
core/binutils/binutils-2.24-CVE-2014-8502.patch
Normal file
547
core/binutils/binutils-2.24-CVE-2014-8502.patch
Normal file
|
@ -0,0 +1,547 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c8ac826..3fcf2d8 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1578,38 +1578,67 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
Elf_Internal_Ehdr *ehdr;
|
||||
const struct elf_backend_data *bed;
|
||||
const char *name;
|
||||
+ bfd_boolean ret = TRUE;
|
||||
+ static bfd_boolean * sections_being_created = NULL;
|
||||
+ static unsigned int nesting = 0;
|
||||
|
||||
if (shindex >= elf_numsections (abfd))
|
||||
return FALSE;
|
||||
|
||||
+ if (++ nesting > 3)
|
||||
+ {
|
||||
+ /* PR17512: A corrupt ELF binary might contain a recursive group of
|
||||
+ sections, each the string indicies pointing to the next in the
|
||||
+ 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])
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: warning: loop in section dependencies detected"), abfd);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ sections_being_created [shindex] = TRUE;
|
||||
+ }
|
||||
+
|
||||
hdr = elf_elfsections (abfd)[shindex];
|
||||
ehdr = elf_elfheader (abfd);
|
||||
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx,
|
||||
hdr->sh_name);
|
||||
if (name == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
bed = get_elf_backend_data (abfd);
|
||||
switch (hdr->sh_type)
|
||||
{
|
||||
case SHT_NULL:
|
||||
/* Inactive section. Throw it away. */
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_PROGBITS: /* Normal section with contents. */
|
||||
- case SHT_NOBITS: /* .bss section. */
|
||||
- case SHT_HASH: /* .hash section. */
|
||||
- case SHT_NOTE: /* .note section. */
|
||||
+ case SHT_PROGBITS: /* Normal section with contents. */
|
||||
+ case SHT_NOBITS: /* .bss section. */
|
||||
+ case SHT_HASH: /* .hash section. */
|
||||
+ case SHT_NOTE: /* .note section. */
|
||||
case SHT_INIT_ARRAY: /* .init_array section. */
|
||||
case SHT_FINI_ARRAY: /* .fini_array section. */
|
||||
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
|
||||
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
|
||||
case SHT_GNU_HASH: /* .gnu.hash section. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_DYNAMIC: /* Dynamic linking information. */
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_link > elf_numsections (abfd))
|
||||
{
|
||||
/* PR 10478: Accept Solaris binaries with a sh_link
|
||||
@@ -1623,11 +1652,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
/* Otherwise fall through. */
|
||||
default:
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
}
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
|
||||
{
|
||||
Elf_Internal_Shdr *dynsymhdr;
|
||||
@@ -1656,24 +1685,26 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB: /* A symbol table */
|
||||
+ case SHT_SYMTAB: /* A symbol table. */
|
||||
if (elf_onesymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
/* Some assemblers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_onesymtab (abfd) == 0);
|
||||
elf_onesymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_hdr = *hdr;
|
||||
@@ -1690,7 +1721,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
&& (abfd->flags & DYNAMIC) != 0
|
||||
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
|
||||
can't read symbols without that section loaded as well. It
|
||||
@@ -1716,26 +1747,29 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
}
|
||||
if (i != shindex)
|
||||
- return bfd_section_from_shdr (abfd, i);
|
||||
+ ret = bfd_section_from_shdr (abfd, i);
|
||||
}
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_DYNSYM: /* A dynamic symbol table */
|
||||
+ case SHT_DYNSYM: /* A dynamic symbol table. */
|
||||
if (elf_dynsymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
/* Some linkers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_dynsymtab (abfd) == 0);
|
||||
elf_dynsymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynsymtab_hdr = *hdr;
|
||||
@@ -1744,34 +1778,38 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|
||||
/* Besides being a symbol table, we also treat this as a regular
|
||||
section, so that objcopy can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */
|
||||
+ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */
|
||||
if (elf_symtab_shndx (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
|
||||
elf_symtab_shndx (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_STRTAB: /* A string table */
|
||||
+ case SHT_STRTAB: /* A string table. */
|
||||
if (hdr->bfd_section != NULL)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
+
|
||||
if (ehdr->e_shstrndx == shindex)
|
||||
{
|
||||
elf_tdata (abfd)->shstrtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
symtab_strtab:
|
||||
elf_tdata (abfd)->strtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
dynsymtab_strtab:
|
||||
@@ -1780,8 +1818,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
elf_elfsections (abfd)[shindex] = hdr;
|
||||
/* We also treat this as a regular section, so that objcopy
|
||||
can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* If the string table isn't one of the above, then treat it as a
|
||||
@@ -1799,9 +1838,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
{
|
||||
/* Prevent endless recursion on broken objects. */
|
||||
if (i == shindex)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (! bfd_section_from_shdr (abfd, i))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (elf_onesymtab (abfd) == i)
|
||||
goto symtab_strtab;
|
||||
if (elf_dynsymtab (abfd) == i)
|
||||
@@ -1809,7 +1848,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
@@ -1824,7 +1864,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (hdr->sh_entsize
|
||||
!= (bfd_size_type) (hdr->sh_type == SHT_REL
|
||||
? bed->s->sizeof_rel : bed->s->sizeof_rela))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Check for a bogus link to avoid crashing. */
|
||||
if (hdr->sh_link >= num_sec)
|
||||
@@ -1832,8 +1872,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
((*_bfd_error_handler)
|
||||
(_("%B: invalid link %lu for reloc section %s (index %u)"),
|
||||
abfd, hdr->sh_link, name, shindex));
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* For some incomprehensible reason Oracle distributes
|
||||
@@ -1874,7 +1915,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|
||||
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
|
||||
&& ! bfd_section_from_shdr (abfd, hdr->sh_link))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* If this reloc section does not use the main symbol table we
|
||||
don't treat it as a reloc section. BFD can't adequately
|
||||
@@ -1889,14 +1930,18 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_info >= num_sec
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
|
||||
if (! bfd_section_from_shdr (abfd, hdr->sh_info))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
|
||||
if (target_sect == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
esdt = elf_section_data (target_sect);
|
||||
if (hdr->sh_type == SHT_RELA)
|
||||
@@ -1908,7 +1953,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
amt = sizeof (*hdr2);
|
||||
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
|
||||
if (hdr2 == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
*hdr2 = *hdr;
|
||||
*p_hdr = hdr2;
|
||||
elf_elfsections (abfd)[shindex] = hdr2;
|
||||
@@ -1924,34 +1969,40 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
target_sect->use_rela_p = 1;
|
||||
}
|
||||
abfd->flags |= HAS_RELOC;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
case SHT_GNU_verdef:
|
||||
elf_dynverdef (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverdef_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_versym:
|
||||
if (hdr->sh_entsize != sizeof (Elf_External_Versym))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
elf_dynversym (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynversym_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_verneed:
|
||||
elf_dynverref (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverref_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_SHLIB:
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
case SHT_GROUP:
|
||||
if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->contents != NULL)
|
||||
{
|
||||
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
|
||||
@@ -1977,7 +2028,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
default:
|
||||
/* Possibly an attributes section. */
|
||||
@@ -1985,14 +2036,14 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_type == bed->obj_attrs_section_type)
|
||||
{
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
_bfd_elf_parse_attributes (abfd, hdr);
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* Check for any processor-specific section types. */
|
||||
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
|
||||
{
|
||||
@@ -2004,9 +2055,12 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"specific section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Allow sections reserved for applications. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ /* Allow sections reserved for applications. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else if (hdr->sh_type >= SHT_LOPROC
|
||||
&& hdr->sh_type <= SHT_HIPROC)
|
||||
@@ -2027,8 +2081,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"`%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Otherwise it should be processed. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ {
|
||||
+ /* Otherwise it should be processed. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
/* FIXME: We should handle this section. */
|
||||
@@ -2036,10 +2093,17 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
(_("%B: don't know how to handle section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
- return TRUE;
|
||||
+ fail:
|
||||
+ ret = FALSE;
|
||||
+ success:
|
||||
+ if (sections_being_created)
|
||||
+ sections_being_created [shindex] = FALSE;
|
||||
+ if (-- nesting == 0)
|
||||
+ sections_being_created = NULL;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/* Return the local symbol specified by ABFD, R_SYMNDX. */
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 987be40..c7d6067 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1705,7 +1705,12 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
_("\nExport Address Table -- Ordinal Base %ld\n"),
|
||||
edt.base);
|
||||
|
||||
- for (i = 0; i < edt.num_functions; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.eat_addr,
|
||||
+ (long) edt.num_functions);
|
||||
+ else for (i = 0; i < edt.num_functions; ++i)
|
||||
{
|
||||
bfd_vma eat_member = bfd_get_32 (abfd,
|
||||
data + edt.eat_addr + (i * 4) - adj);
|
||||
@@ -1741,7 +1746,16 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
fprintf (file,
|
||||
_("\n[Ordinal/Name Pointer] Table\n"));
|
||||
|
||||
- for (i = 0; i < edt.num_names; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.npt_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.ot_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else for (i = 0; i < edt.num_names; ++i)
|
||||
{
|
||||
bfd_vma name_ptr = bfd_get_32 (abfd,
|
||||
data +
|
||||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index 949221f..b5fc84b 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1580,6 +1580,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
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))
|
||||
@@ -1592,13 +1593,19 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
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. */
|
||||
-
|
||||
+ 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])
|
||||
{
|
||||
@@ -2102,7 +2109,10 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (sections_being_created)
|
||||
sections_being_created [shindex] = FALSE;
|
||||
if (-- nesting == 0)
|
||||
- sections_being_created = NULL;
|
||||
+ {
|
||||
+ sections_being_created = NULL;
|
||||
+ sections_being_created_abfd = abfd;
|
||||
+ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 6129085..1a5cb31 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1611,6 +1611,15 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* 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);
|
||||
|
||||
--
|
||||
1.7.1
|
||||
|
16
core/binutils/binutils-2.24-CVE-2014-8503.patch
Normal file
16
core/binutils/binutils-2.24-CVE-2014-8503.patch
Normal file
|
@ -0,0 +1,16 @@
|
|||
diff --git a/bfd/ihex.c b/bfd/ihex.c
|
||||
index 8d3590d..9b3b813 100644
|
||||
--- a/bfd/ihex.c
|
||||
+++ b/bfd/ihex.c
|
||||
@@ -321,7 +321,7 @@ ihex_scan (bfd *abfd)
|
||||
{
|
||||
if (! ISHEX (buf[i]))
|
||||
{
|
||||
- ihex_bad_byte (abfd, lineno, hdr[i], error);
|
||||
+ ihex_bad_byte (abfd, lineno, buf[i], error);
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
--
|
||||
1.7.1
|
||||
|
50
core/binutils/binutils-2.24-CVE-2014-8504.patch
Normal file
50
core/binutils/binutils-2.24-CVE-2014-8504.patch
Normal file
|
@ -0,0 +1,50 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index 3fcf2d8..949221f 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -629,7 +629,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
memset (shdr->contents, 0, amt);
|
||||
continue;
|
||||
}
|
||||
-
|
||||
+
|
||||
/* Translate raw contents, a flag word followed by an
|
||||
array of elf section indices all in target byte order,
|
||||
to the flag word followed by an array of elf section
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index c7d6067..6129085 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -515,7 +515,6 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
|
||||
a->NumberOfRvaAndSizes = 0;
|
||||
}
|
||||
|
||||
-
|
||||
for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
|
||||
{
|
||||
/* If data directory is empty, rva also should be 0. */
|
||||
diff --git a/bfd/srec.c b/bfd/srec.c
|
||||
index 9ed2080..5f9a546 100644
|
||||
--- a/bfd/srec.c
|
||||
+++ b/bfd/srec.c
|
||||
@@ -246,7 +246,7 @@ srec_bad_byte (bfd *abfd,
|
||||
}
|
||||
else
|
||||
{
|
||||
- char buf[10];
|
||||
+ char buf[40];
|
||||
|
||||
if (! ISPRINT (c))
|
||||
sprintf (buf, "\\%03o", (unsigned int) c);
|
||||
@@ -452,7 +452,7 @@ srec_scan (bfd *abfd)
|
||||
case 'S':
|
||||
{
|
||||
file_ptr pos;
|
||||
- char hdr[3];
|
||||
+ unsigned char hdr[3];
|
||||
unsigned int bytes, min_bytes;
|
||||
bfd_vma address;
|
||||
bfd_byte *data;
|
||||
--
|
||||
1.7.1
|
||||
|
128
core/binutils/binutils-2.24-CVE-2014-8737.patch
Normal file
128
core/binutils/binutils-2.24-CVE-2014-8737.patch
Normal file
|
@ -0,0 +1,128 @@
|
|||
diff --git a/binutils/ar.c b/binutils/ar.c
|
||||
index ebd9528..117826d 100644
|
||||
--- a/binutils/ar.c
|
||||
+++ b/binutils/ar.c
|
||||
@@ -1034,6 +1034,15 @@ extract_file (bfd *abfd)
|
||||
bfd_size_type size;
|
||||
struct stat buf;
|
||||
|
||||
+ /* PR binutils/17533: Do not allow directory traversal
|
||||
+ outside of the current directory tree. */
|
||||
+ if (! is_valid_archive_path (bfd_get_filename (abfd)))
|
||||
+ {
|
||||
+ non_fatal (_("illegal pathname found in archive member: %s"),
|
||||
+ bfd_get_filename (abfd));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (bfd_stat_arch_elt (abfd, &buf) != 0)
|
||||
/* xgettext:c-format */
|
||||
fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
|
||||
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
|
||||
index fd73070..b8deff5 100644
|
||||
--- a/binutils/bucomm.c
|
||||
+++ b/binutils/bucomm.c
|
||||
@@ -624,3 +624,29 @@ bfd_get_archive_filename (const bfd *abfd)
|
||||
bfd_get_filename (abfd));
|
||||
return buf;
|
||||
}
|
||||
+
|
||||
+/* Returns TRUE iff PATHNAME, a filename of an archive member,
|
||||
+ is valid for writing. For security reasons absolute paths
|
||||
+ and paths containing /../ are not allowed. See PR 17533. */
|
||||
+
|
||||
+bfd_boolean
|
||||
+is_valid_archive_path (char const * pathname)
|
||||
+{
|
||||
+ const char * n = pathname;
|
||||
+
|
||||
+ if (IS_ABSOLUTE_PATH (n))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ while (*n)
|
||||
+ {
|
||||
+ if (*n == '.' && *++n == '.' && ( ! *++n || IS_DIR_SEPARATOR (*n)))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ while (*n && ! IS_DIR_SEPARATOR (*n))
|
||||
+ n++;
|
||||
+ while (IS_DIR_SEPARATOR (*n))
|
||||
+ n++;
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
diff --git a/binutils/bucomm.h b/binutils/bucomm.h
|
||||
index a93c378..a71a8fb 100644
|
||||
--- a/binutils/bucomm.h
|
||||
+++ b/binutils/bucomm.h
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef _BUCOMM_H
|
||||
#define _BUCOMM_H
|
||||
|
||||
+/* In bucomm.c. */
|
||||
+
|
||||
/* Return the filename in a static buffer. */
|
||||
const char *bfd_get_archive_filename (const bfd *);
|
||||
|
||||
@@ -56,20 +58,22 @@ bfd_vma parse_vma (const char *, const char *);
|
||||
|
||||
off_t get_file_size (const char *);
|
||||
|
||||
+bfd_boolean is_valid_archive_path (char const *);
|
||||
+
|
||||
extern char *program_name;
|
||||
|
||||
-/* filemode.c */
|
||||
+/* In filemode.c. */
|
||||
void mode_string (unsigned long, char *);
|
||||
|
||||
-/* version.c */
|
||||
+/* In version.c. */
|
||||
extern void print_version (const char *);
|
||||
|
||||
-/* rename.c */
|
||||
+/* In rename.c. */
|
||||
extern void set_times (const char *, const struct stat *);
|
||||
|
||||
extern int smart_rename (const char *, const char *, int);
|
||||
|
||||
-/* libiberty. */
|
||||
+/* In libiberty. */
|
||||
void *xmalloc (size_t);
|
||||
|
||||
void *xrealloc (void *, size_t);
|
||||
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
|
||||
index eee77b1..39eb1d2 100644
|
||||
--- a/binutils/doc/binutils.texi
|
||||
+++ b/binutils/doc/binutils.texi
|
||||
@@ -234,7 +234,8 @@ a normal archive. Instead the elements of the first archive are added
|
||||
individually to the second archive.
|
||||
|
||||
The paths to the elements of the archive are stored relative to the
|
||||
-archive itself.
|
||||
+archive itself. For security reasons absolute paths and paths with a
|
||||
+@code{/../} component are not allowed.
|
||||
|
||||
@cindex compatibility, @command{ar}
|
||||
@cindex @command{ar} compatibility
|
||||
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
|
||||
index 3b353ad..8454bc6 100644
|
||||
--- a/binutils/objcopy.c
|
||||
+++ b/binutils/objcopy.c
|
||||
@@ -2295,6 +2295,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
|
||||
bfd_boolean del = TRUE;
|
||||
bfd_boolean ok_object;
|
||||
|
||||
+ /* PR binutils/17533: Do not allow directory traversal
|
||||
+ outside of the current directory tree by archive members. */
|
||||
+ if (! is_valid_archive_path (bfd_get_filename (this_element)))
|
||||
+ fatal (_("illegal pathname found in archive member: %s"),
|
||||
+ bfd_get_filename (this_element));
|
||||
+
|
||||
/* Create an output file for this member. */
|
||||
output_name = concat (dir, "/",
|
||||
bfd_get_filename (this_element), (char *) 0);
|
||||
--
|
||||
1.7.1
|
||||
|
48
core/binutils/binutils-2.24-CVE-2014-8738.patch
Normal file
48
core/binutils/binutils-2.24-CVE-2014-8738.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
diff --git a/bfd/archive.c b/bfd/archive.c
|
||||
index 40a3395..b905213 100644
|
||||
--- a/bfd/archive.c
|
||||
+++ b/bfd/archive.c
|
||||
@@ -1293,6 +1293,9 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
amt = namedata->parsed_size;
|
||||
if (amt + 1 == 0)
|
||||
goto byebye;
|
||||
+ /* PR binutils/17533: A corrupt archive can contain an invalid size. */
|
||||
+ if (amt > (bfd_size_type) bfd_get_size (abfd))
|
||||
+ goto byebye;
|
||||
|
||||
bfd_ardata (abfd)->extended_names_size = amt;
|
||||
bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1);
|
||||
@@ -1300,6 +1303,8 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
{
|
||||
byebye:
|
||||
free (namedata);
|
||||
+ bfd_ardata (abfd)->extended_names = NULL;
|
||||
+ bfd_ardata (abfd)->extended_names_size = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1308,7 +1313,6 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
bfd_release (abfd, (bfd_ardata (abfd)->extended_names));
|
||||
- bfd_ardata (abfd)->extended_names = NULL;
|
||||
goto byebye;
|
||||
}
|
||||
|
||||
@@ -1316,11 +1320,12 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
text, the entries in the list are newline-padded, not null
|
||||
padded. In SVR4-style archives, the names also have a
|
||||
trailing '/'. DOS/NT created archive often have \ in them
|
||||
- We'll fix all problems here.. */
|
||||
+ We'll fix all problems here. */
|
||||
{
|
||||
char *ext_names = bfd_ardata (abfd)->extended_names;
|
||||
char *temp = ext_names;
|
||||
char *limit = temp + namedata->parsed_size;
|
||||
+
|
||||
for (; temp < limit; ++temp)
|
||||
{
|
||||
if (*temp == ARFMAG[1])
|
||||
--
|
||||
1.7.1
|
||||
|
310
core/binutils/binutils-2.24-strings-all-default.patch
Normal file
310
core/binutils/binutils-2.24-strings-all-default.patch
Normal file
|
@ -0,0 +1,310 @@
|
|||
diff -cpr ../binutils-2.24.orig/binutils/config.in binutils/config.in
|
||||
*** ../binutils-2.24.orig/binutils/config.in 2014-10-31 11:50:20.455222877 +0000
|
||||
--- binutils/config.in 2014-10-31 11:59:05.021241036 +0000
|
||||
***************
|
||||
*** 18,23 ****
|
||||
--- 18,26 ----
|
||||
/* Should ar and ranlib use -D behavior by default? */
|
||||
#undef DEFAULT_AR_DETERMINISTIC
|
||||
|
||||
+ /* Should strings use -a behavior by default? */
|
||||
+ #undef DEFAULT_STRINGS_ALL
|
||||
+
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
diff -cpr ../binutils-2.24.orig/binutils/configure binutils/configure
|
||||
*** ../binutils-2.24.orig/binutils/configure 2014-10-31 11:50:20.590223736 +0000
|
||||
--- binutils/configure 2014-10-31 12:01:46.570102643 +0000
|
||||
*************** with_gnu_ld
|
||||
*** 772,777 ****
|
||||
--- 772,778 ----
|
||||
enable_libtool_lock
|
||||
enable_targets
|
||||
enable_deterministic_archives
|
||||
+ enable_default_strings_all
|
||||
enable_werror
|
||||
enable_build_warnings
|
||||
enable_nls
|
||||
*************** Optional Features:
|
||||
*** 1421,1426 ****
|
||||
--- 1422,1429 ----
|
||||
--enable-targets alternative target configurations
|
||||
--enable-deterministic-archives
|
||||
ar and ranlib default to -D behavior
|
||||
+ --disable-default-strings-all
|
||||
+ strings defaults to --data behavior
|
||||
--enable-werror treat compile warnings as errors
|
||||
--enable-build-warnings enable build-time compiler warnings
|
||||
--disable-nls do not use Native Language Support
|
||||
*************** cat >>confdefs.h <<_ACEOF
|
||||
*** 11615,11620 ****
|
||||
--- 11594,11618 ----
|
||||
_ACEOF
|
||||
|
||||
|
||||
+ # Check whether --enable-default-strings-all was given.
|
||||
+ if test "${enable_default_strings_all+set}" = set; then :
|
||||
+ enableval=$enable_default_strings_all;
|
||||
+ if test "${enableval}" = no; then
|
||||
+ default_strings_all=0
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi
|
||||
+
|
||||
+
|
||||
+
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+ #define DEFAULT_STRINGS_ALL $default_strings_all
|
||||
+ _ACEOF
|
||||
+
|
||||
+
|
||||
|
||||
GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
diff -cpr ../binutils-2.24.orig/binutils/configure.in binutils/configure.in
|
||||
*** ../binutils-2.24.orig/binutils/configure.in 2014-10-31 11:50:20.430222717 +0000
|
||||
--- binutils/configure.in 2014-10-31 12:00:48.092790946 +0000
|
||||
*************** fi], [default_ar_deterministic=0])
|
||||
*** 57,62 ****
|
||||
--- 57,74 ----
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic,
|
||||
[Should ar and ranlib use -D behavior by default?])
|
||||
|
||||
+ AC_ARG_ENABLE(default-strings-all,
|
||||
+ [AS_HELP_STRING([--disable-default-strings-all],
|
||||
+ [strings defaults to --data behavior])], [
|
||||
+ if test "${enableval}" = no; then
|
||||
+ default_strings_all=0
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi], [default_strings_all=1])
|
||||
+
|
||||
+ AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all,
|
||||
+ [Should strings use -a behavior by default?])
|
||||
+
|
||||
AM_BINUTILS_WARNINGS
|
||||
|
||||
AC_CONFIG_HEADERS(config.h:config.in)
|
||||
diff -cpr ../binutils-2.24.orig/binutils/doc/binutils.texi binutils/doc/binutils.texi
|
||||
*** ../binutils-2.24.orig/binutils/doc/binutils.texi 2014-10-31 11:50:20.579223666 +0000
|
||||
--- binutils/doc/binutils.texi 2014-10-31 11:59:23.052339164 +0000
|
||||
*************** strings [@option{-afovV}] [@option{-}@va
|
||||
*** 2653,2667 ****
|
||||
|
||||
@c man begin DESCRIPTION strings
|
||||
|
||||
! For each @var{file} given, @sc{gnu} @command{strings} prints the printable
|
||||
! character sequences that are at least 4 characters long (or the number
|
||||
! given with the options below) and are followed by an unprintable
|
||||
! character. By default, it only prints the strings from the initialized
|
||||
! and loaded sections of object files; for other types of files, it prints
|
||||
! the strings from the whole file.
|
||||
|
||||
! @command{strings} is mainly useful for determining the contents of non-text
|
||||
! files.
|
||||
|
||||
@c man end
|
||||
|
||||
--- 2653,2676 ----
|
||||
|
||||
@c man begin DESCRIPTION strings
|
||||
|
||||
! For each @var{file} given, @sc{gnu} @command{strings} prints the
|
||||
! printable character sequences that are at least 4 characters long (or
|
||||
! the number given with the options below) and are followed by an
|
||||
! unprintable character.
|
||||
!
|
||||
! Depending upon how the strings program was configured it will default
|
||||
! to either displaying all the printable sequences that it can find in
|
||||
! each file, or only those sequences that are in loadable, initialized
|
||||
! data sections. If the file type in unrecognizable, or if strings is
|
||||
! reading from stdin then it will always display all of the printable
|
||||
! sequences that it can find.
|
||||
!
|
||||
! For backwards compatibility any file that occurs after a command line
|
||||
! option of just @option{-} will also be scanned in full, regardless of
|
||||
! the presence of any @option{-d} option.
|
||||
|
||||
! @command{strings} is mainly useful for determining the contents of
|
||||
! non-text files.
|
||||
|
||||
@c man end
|
||||
|
||||
*************** files.
|
||||
*** 2671,2678 ****
|
||||
@item -a
|
||||
@itemx --all
|
||||
@itemx -
|
||||
! Do not scan only the initialized and loaded sections of object files;
|
||||
! scan the whole files.
|
||||
|
||||
@item -f
|
||||
@itemx --print-file-name
|
||||
--- 2680,2704 ----
|
||||
@item -a
|
||||
@itemx --all
|
||||
@itemx -
|
||||
! Scan the whole file, regardless of what sections it contains or
|
||||
! whether those sections are loaded or initialized. Normally this is
|
||||
! the default behaviour, but strings can be configured so that the
|
||||
! @option{-d} is the default instead.
|
||||
!
|
||||
! The @option{-} option is position dependent and forces strings to
|
||||
! perform full scans of any file that is mentioned after the @option{-}
|
||||
! on the command line, even if the @option{-d} option has been
|
||||
! specified.
|
||||
!
|
||||
! @item -d
|
||||
! @itemx --data
|
||||
! Only print strings from initialized, loaded data sections in the
|
||||
! file. This may reduce the amount of garbage in the output, but it
|
||||
! also exposes the strings program to any security flaws that may be
|
||||
! present in the BFD library used to scan and load sections. Strings
|
||||
! can be configured so that this option is the default behaviour. In
|
||||
! such cases the @option{-a} option can be used to avoid using the BFD
|
||||
! library and instead just print all of the strings found in the file.
|
||||
|
||||
@item -f
|
||||
@itemx --print-file-name
|
||||
diff -cpr ../binutils-2.24.orig/binutils/NEWS binutils/NEWS
|
||||
*** ../binutils-2.24.orig/binutils/NEWS 2014-10-31 11:50:20.338222131 +0000
|
||||
--- binutils/NEWS 2014-10-31 11:59:52.315493579 +0000
|
||||
***************
|
||||
*** 1,5 ****
|
||||
--- 1,10 ----
|
||||
-*- text -*-
|
||||
|
||||
+ * Add --data option to strings to only print strings in loadable, initialized
|
||||
+ data sections. Change the default behaviour to be --all, but add a new
|
||||
+ configure time option of --disable-default-strings-all to restore the old
|
||||
+ default behaviour.
|
||||
+
|
||||
Changes in 2.24:
|
||||
|
||||
* Objcopy now supports wildcard characters in command line options that take
|
||||
diff -cpr ../binutils-2.24.orig/binutils/strings.c binutils/strings.c
|
||||
*** ../binutils-2.24.orig/binutils/strings.c 2014-10-31 11:50:20.464222934 +0000
|
||||
--- binutils/strings.c 2014-10-31 12:01:33.901035485 +0000
|
||||
***************
|
||||
*** 23,29 ****
|
||||
Options:
|
||||
--all
|
||||
-a
|
||||
! - Do not scan only the initialized data section of object files.
|
||||
|
||||
--print-file-name
|
||||
-f Print the name of the file before each string.
|
||||
--- 23,32 ----
|
||||
Options:
|
||||
--all
|
||||
-a
|
||||
! - Scan each file in its entirety.
|
||||
!
|
||||
! --data
|
||||
! -d Scan only the initialized data section(s) of object files.
|
||||
|
||||
--print-file-name
|
||||
-f Print the name of the file before each string.
|
||||
*************** static int encoding_bytes;
|
||||
*** 107,112 ****
|
||||
--- 110,116 ----
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
+ {"data", no_argument, NULL, 'd'},
|
||||
{"print-file-name", no_argument, NULL, 'f'},
|
||||
{"bytes", required_argument, NULL, 'n'},
|
||||
{"radix", required_argument, NULL, 't'},
|
||||
*************** typedef struct
|
||||
*** 128,134 ****
|
||||
|
||||
static void strings_a_section (bfd *, asection *, void *);
|
||||
static bfd_boolean strings_object_file (const char *);
|
||||
! static bfd_boolean strings_file (char *file);
|
||||
static void print_strings (const char *, FILE *, file_ptr, int, int, char *);
|
||||
static void usage (FILE *, int);
|
||||
static long get_char (FILE *, file_ptr *, int *, char **);
|
||||
--- 132,138 ----
|
||||
|
||||
static void strings_a_section (bfd *, asection *, void *);
|
||||
static bfd_boolean strings_object_file (const char *);
|
||||
! static bfd_boolean strings_file (char *);
|
||||
static void print_strings (const char *, FILE *, file_ptr, int, int, char *);
|
||||
static void usage (FILE *, int);
|
||||
static long get_char (FILE *, file_ptr *, int *, char **);
|
||||
*************** main (int argc, char **argv)
|
||||
*** 158,168 ****
|
||||
string_min = 4;
|
||||
print_addresses = FALSE;
|
||||
print_filenames = FALSE;
|
||||
! datasection_only = TRUE;
|
||||
target = NULL;
|
||||
encoding = 's';
|
||||
|
||||
! while ((optc = getopt_long (argc, argv, "afhHn:ot:e:T:Vv0123456789",
|
||||
long_options, (int *) 0)) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
--- 162,175 ----
|
||||
string_min = 4;
|
||||
print_addresses = FALSE;
|
||||
print_filenames = FALSE;
|
||||
! if (DEFAULT_STRINGS_ALL)
|
||||
! datasection_only = FALSE;
|
||||
! else
|
||||
! datasection_only = TRUE;
|
||||
target = NULL;
|
||||
encoding = 's';
|
||||
|
||||
! while ((optc = getopt_long (argc, argv, "adfhHn:ot:e:T:Vv0123456789",
|
||||
long_options, (int *) 0)) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
*************** main (int argc, char **argv)
|
||||
*** 171,176 ****
|
||||
--- 178,187 ----
|
||||
datasection_only = FALSE;
|
||||
break;
|
||||
|
||||
+ case 'd':
|
||||
+ datasection_only = TRUE;
|
||||
+ break;
|
||||
+
|
||||
case 'f':
|
||||
print_filenames = TRUE;
|
||||
break;
|
||||
*************** usage (FILE *stream, int status)
|
||||
*** 635,642 ****
|
||||
{
|
||||
fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
|
||||
fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n"));
|
||||
! fprintf (stream, _(" The options are:\n\
|
||||
-a - --all Scan the entire file, not just the data section\n\
|
||||
-f --print-file-name Print the name of the file before each string\n\
|
||||
-n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\
|
||||
-<number> least [number] characters (default 4).\n\
|
||||
--- 646,663 ----
|
||||
{
|
||||
fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
|
||||
fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n"));
|
||||
! fprintf (stream, _(" The options are:\n"));
|
||||
!
|
||||
! if (DEFAULT_STRINGS_ALL)
|
||||
! fprintf (stream, _("\
|
||||
! -a - --all Scan the entire file, not just the data section [default]\n\
|
||||
! -d --data Only scan the data sections in the file\n"));
|
||||
! else
|
||||
! fprintf (stream, _("\
|
||||
-a - --all Scan the entire file, not just the data section\n\
|
||||
+ -d --data Only scan the data sections in the file [default]\n"));
|
||||
+
|
||||
+ fprintf (stream, _("\
|
||||
-f --print-file-name Print the name of the file before each string\n\
|
||||
-n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\
|
||||
-<number> least [number] characters (default 4).\n\
|
||||
|
||||
Only in binutils: strings.c.rej
|
Loading…
Reference in a new issue