From: Nick Clifton Date: Wed, 21 Jun 2017 12:18:46 +0000 (+0100) Subject: Fix seg-fault in the BFD parsing a corrupt input binary. X-Git-Tag: users/hjl/linux/release/2.28.51.0.1~1^2~9^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20bd1b6ba53491e4979c03a4f679d0d17b9b9046;p=thirdparty%2Fbinutils-gdb.git Fix seg-fault in the BFD parsing a corrupt input binary. PR binutils/21645 * reloc.c (bfd_generic_get_relocated_section_contents): Fail if bfd_get_full_section_contents returns no contents. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c92ed679f5e..1d9ba02a577 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-06-21 Nick Clifton + + 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 PR binutils/21638 diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index dd8090c6703..d76f98ad059 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -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 diff --git a/bfd/reloc.c b/bfd/reloc.c index 8dedfe82bf0..ee01d88833b 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -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;