Fix seg-fault in the BFD parsing a corrupt input binary.
authorNick Clifton <nickc@redhat.com>
Wed, 21 Jun 2017 12:18:46 +0000 (13:18 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 21 Jun 2017 12:18:46 +0000 (13:18 +0100)
PR binutils/21645
* reloc.c (bfd_generic_get_relocated_section_contents): Fail if
bfd_get_full_section_contents returns no contents.

bfd/ChangeLog
bfd/coff-sh.c
bfd/reloc.c

index c92ed679f5eacbfef3831e56bf73561914557afa..1d9ba02a5771d01982d849250e731462ae6b8cb3 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-21  Nick Clifton  <nickc@redhat.com>
+
+       PR binutils/21645
+       * reloc.c (bfd_generic_get_relocated_section_contents): Fail if
+       bfd_get_full_section_contents returns no contents.
+
 2017-06-21  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/21638
index dd8090c67033a749bdd14222ddf8e0e293fc56fc..d76f98ad059bb0b5b6b492d53af3d70fc076eaea 100644 (file)
@@ -2910,6 +2910,7 @@ sh_coff_get_relocated_section_contents (bfd *output_bfd,
   struct internal_reloc *internal_relocs = NULL;
   struct internal_syment *internal_syms = NULL;
 
+fprintf (stderr, "DATA = %p\n", data);
   /* We only need to handle the case of relaxing, or of having a
      particular set of section contents, specially.  */
   if (relocatable
index 8dedfe82bf044b0b219f90c607c79862f207db15..ee01d88833b1a495333dc8801383e445026f07e6 100644 (file)
@@ -8126,6 +8126,9 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
   if (!bfd_get_full_section_contents (input_bfd, input_section, &data))
     return NULL;
 
+  if (data == NULL)
+    return NULL;
+
   if (reloc_size == 0)
     return data;