Revert bfd_get_size checks
authorAlan Modra <amodra@gmail.com>
Thu, 6 Nov 2014 23:07:39 +0000 (09:37 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 7 Nov 2014 02:49:15 +0000 (13:19 +1030)
* archive.c (_bfd_slurp_extended_name_table): Revert bfd_get_size check.
* coffcode.h (coff_set_alignment_hook): Likewise.
(coff_slurp_line_table): Likewise.
* coffgen.c (coff_get_normalized_symtab): Likewise.
(_bfd_coff_get_external_symbols): Likewise.
* elf.c (bfd_elf_get_str_section): Likewise.
* tekhex.c (first_phase): Likewise.

bfd/ChangeLog
bfd/archive.c
bfd/coffcode.h
bfd/coffgen.c
bfd/elf.c
bfd/tekhex.c

index 97057d46dc0cc0c78e4bb86b341eff6b44aaaa42..27edf4fbf115f1272da1d4bab6fdf09a23af618a 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-07  Alan Modra  <amodra@gmail.com>
+
+       * archive.c (_bfd_slurp_extended_name_table): Revert bfd_get_size check.
+       * coffcode.h (coff_set_alignment_hook): Likewise.
+       (coff_slurp_line_table): Likewise.
+       * coffgen.c (coff_get_normalized_symtab): Likewise.
+       (_bfd_coff_get_external_symbols): Likewise.
+       * elf.c (bfd_elf_get_str_section): Likewise.
+       * tekhex.c (first_phase): Likewise.
+
 2014-11-06  Nick Clifton  <nickc@redhat.com>
 
        * aoutx.h (slurp_symbol_table): Revert previous delta.
index b9052135101d864082ec615053891e633f89da0c..9e94745ff46996e727bbabbac45a1319b34106c8 100644 (file)
@@ -1293,9 +1293,6 @@ _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);
index 1ca28b82f78c5b66e6a8d9d6362cab89aa63c325..3abb6a3df62a19766a8513d09ab0c8df997ddc0b 100644 (file)
@@ -1919,15 +1919,6 @@ coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
       if (bfd_seek (abfd, oldpos, 0) != 0)
        return;
       section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
-      /* PR binutils/17512: Stop corrupt files from causing
-        memory problems if they claim to have too many relocs.  */
-      if (section->reloc_count * relsz > (bfd_size_type) bfd_get_size (abfd))
-       {
-         (*_bfd_error_handler)
-           ("%s: warning: claims to have %#x relocs, but the file is not that big",
-            bfd_get_filename (abfd), section->reloc_count);
-         section->reloc_count = 0;
-       }
       section->rel_filepos += relsz;
     }
   else if (hdr->s_nreloc == 0xffff)
@@ -4528,8 +4519,6 @@ coff_slurp_line_table (bfd *abfd, asection *asect)
   BFD_ASSERT (asect->lineno == NULL);
 
   amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent);
-  if (amt > (bfd_size_type) bfd_get_size (abfd))
-    return FALSE;
   lineno_cache = (alent *) bfd_zalloc (abfd, amt);
   if (lineno_cache == NULL)
     return FALSE;
index 4856a40e5e72e3d227099d090366bdbe5648d961..9ad0783babfb78b35fc88a9fef039b4d0213aebd 100644 (file)
@@ -1619,14 +1619,6 @@ _bfd_coff_get_external_symbols (bfd *abfd)
   if (size == 0)
     return TRUE;
 
-  /* PR binutils/17512: Do not even try to load
-     a symbol table bigger than the entire file...  */
-  if (size >= (bfd_size_type) bfd_get_size (abfd))
-    {
-      fprintf (stderr, "XXX SIZE FAIL 1\n");
-    return FALSE;
-    }
-
   syms = bfd_malloc (size);
   if (syms == NULL)
     return FALSE;
@@ -1759,16 +1751,7 @@ coff_get_normalized_symtab (bfd *abfd)
   if (obj_raw_syments (abfd) != NULL)
     return obj_raw_syments (abfd);
 
-  size = obj_raw_syment_count (abfd);
-  /* PR binutils/17512: Do not even try to load
-     a symbol table bigger than the entire file...
-     Note - we do not fail on a size of 0.  Linker created
-     bfds can have this property and they are not corrupt.  */
-  if (size >= (bfd_size_type) bfd_get_size (abfd)
-      && bfd_get_size (abfd) > 0)
-    return NULL;
-
-  size *= sizeof (combined_entry_type);
+  size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
   internal = (combined_entry_type *) bfd_zalloc (abfd, size);
   if (internal == NULL && size != 0)
     return NULL;
index 7cc0ce1fa6b8030d7b386da341270b3ecd5bceef..9c4dcdf452d1ab43c89d38b082214d0f694d3894 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -294,11 +294,6 @@ bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
       offset = i_shdrp[shindex]->sh_offset;
       shstrtabsize = i_shdrp[shindex]->sh_size;
 
-      /* PR binutils/17512: Do not even try to load
-        a string table bigger than the entire file...  */
-      if (shstrtabsize >= (bfd_size_type) bfd_get_size (abfd))
-       return NULL;
-
       /* Allocate and clear an extra byte at the end, to prevent crashes
         in case the string table is not terminated.  */
       if (shstrtabsize + 1 <= 1
index 85f55931c3f2313bd2fb3eb661ecb00e64050b2e..2220d50c1e6a44f9b31ce00890f2b03f29d6e3d3 100644 (file)
@@ -403,9 +403,6 @@ first_phase (bfd *abfd, int type, char *src)
              if (!getvalue (&src, &val))
                return FALSE;
              section->size = val - section->vma;
-             /* PR binutils/17512: Make sure that the size is sane.  */
-             if (section->size > (bfd_size_type) bfd_get_size (abfd))
-               return FALSE;
              section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
              break;
            case '0':
This page took 0.031704 seconds and 4 git commands to generate.