rpms/binutils/devel binutils-2.15.94.0.2-robustify.patch,1.3,1.4

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Sat Jun 11 00:09:38 UTC 2005


Author: jakub

Update of /cvs/dist/rpms/binutils/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv5912

Modified Files:
	binutils-2.15.94.0.2-robustify.patch 
Log Message:
2.15.94.0.2.2

binutils-2.15.94.0.2-robustify.patch:
 archive.c |    6 ++++
 elf.c     |   57 +++++++++++++++++++++++++--------------------
 elfcode.h |   77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 109 insertions(+), 31 deletions(-)

Index: binutils-2.15.94.0.2-robustify.patch
===================================================================
RCS file: /cvs/dist/rpms/binutils/devel/binutils-2.15.94.0.2-robustify.patch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- binutils-2.15.94.0.2-robustify.patch	10 Jun 2005 23:27:26 -0000	1.3
+++ binutils-2.15.94.0.2-robustify.patch	11 Jun 2005 00:09:35 -0000	1.4
@@ -1,5 +1,9 @@
 2005-06-11  Jakub Jelinek  <jakub at redhat.com>
 
+	* elf.c (bfd_elf_get_str_section): Allocate an extra byte after
+	the end of strtab and clear it.
+	(elf_read): Remove.
+
 	* elf.c (bfd_section_from_shdr): Fail if name is NULL.
 	Prevent endless recursion on broken objects.
 
@@ -28,7 +32,59 @@
 
 --- bfd/elf.c.jj	2005-02-07 14:42:44.000000000 -0500
 +++ bfd/elf.c	2005-06-10 19:22:09.000000000 -0400
-@@ -443,8 +443,11 @@ group_signature (bfd *abfd, Elf_Internal
+@@ -206,28 +206,6 @@ bfd_elf_hash (const char *namearg)
+   return h & 0xffffffff;
+ }
+ 
+-/* Read a specified number of bytes at a specified offset in an ELF
+-   file, into a newly allocated buffer, and return a pointer to the
+-   buffer.  */
+-
+-static char *
+-elf_read (bfd *abfd, file_ptr offset, bfd_size_type size)
+-{
+-  char *buf;
+-
+-  if ((buf = bfd_alloc (abfd, size)) == NULL)
+-    return NULL;
+-  if (bfd_seek (abfd, offset, SEEK_SET) != 0)
+-    return NULL;
+-  if (bfd_bread (buf, size, abfd) != size)
+-    {
+-      if (bfd_get_error () != bfd_error_system_call)
+-	bfd_set_error (bfd_error_file_truncated);
+-      return NULL;
+-    }
+-  return buf;
+-}
+-
+ bfd_boolean
+ bfd_elf_mkobject (bfd *abfd)
+ {
+@@ -267,7 +245,21 @@ bfd_elf_get_str_section (bfd *abfd, unsi
+       /* No cached one, attempt to read, and cache what we read.  */
+       offset = i_shdrp[shindex]->sh_offset;
+       shstrtabsize = i_shdrp[shindex]->sh_size;
+-      shstrtab = elf_read (abfd, offset, shstrtabsize);
++
++      /* Allocate and clear an extra byte at the end, to prevent crashes
++	 in case the string table is not terminated.  */
++      if (shstrtabsize + 1 == 0
++	  || (shstrtab = bfd_alloc (abfd, shstrtabsize + 1)) == NULL
++	  || bfd_seek (abfd, offset, SEEK_SET) != 0)
++	shstrtab = NULL;
++      else if (bfd_bread (shstrtab, shstrtabsize, abfd) != shstrtabsize)
++	{
++	  if (bfd_get_error () != bfd_error_system_call)
++	    bfd_set_error (bfd_error_file_truncated);
++	  shstrtab = NULL;
++	}
++      else
++	shstrtab[shstrtabsize] = '\0';
+       i_shdrp[shindex]->contents = shstrtab;
+     }
+   return shstrtab;
+@@ -443,8 +435,11 @@ group_signature (bfd *abfd, Elf_Internal
    Elf_External_Sym_Shndx eshndx;
    Elf_Internal_Sym isym;
  
@@ -42,7 +98,7 @@
      return NULL;
  
    /* Go read the symbol.  */
-@@ -1735,6 +1738,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
+@@ -1735,6 +1730,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
    name = bfd_elf_string_from_elf_section (abfd,
  					  elf_elfheader (abfd)->e_shstrndx,
  					  hdr->sh_name);
@@ -51,7 +107,7 @@
  
    switch (hdr->sh_type)
      {
-@@ -1755,6 +1760,9 @@ bfd_section_from_shdr (bfd *abfd, unsign
+@@ -1755,6 +1752,9 @@ bfd_section_from_shdr (bfd *abfd, unsign
      case SHT_DYNAMIC:	/* Dynamic linking information.  */
        if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
  	return FALSE;
@@ -61,7 +117,7 @@
        if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
  	{
  	  Elf_Internal_Shdr *dynsymhdr;
-@@ -1900,6 +1908,9 @@ bfd_section_from_shdr (bfd *abfd, unsign
+@@ -1900,6 +1900,9 @@ bfd_section_from_shdr (bfd *abfd, unsign
  	      Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i];
  	      if (hdr2->sh_link == shindex)
  		{
@@ -71,7 +127,7 @@
  		  if (! bfd_section_from_shdr (abfd, i))
  		    return FALSE;
  		  if (elf_onesymtab (abfd) == i)
-@@ -1975,6 +1986,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
+@@ -1975,6 +1978,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
  	if (hdr->sh_link != elf_onesymtab (abfd) || hdr->sh_info == SHN_UNDEF)
  	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
  




More information about the fedora-cvs-commits mailing list