diff options
author | Nick Clifton <nickc@redhat.com> | 2020-03-17 17:02:15 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-03-17 17:02:15 +0000 |
commit | 327ef784ba105f067f5c1d587908259d7aabb971 (patch) | |
tree | 53a9080f38c3060cb5218a02e6fbccc05546968b /bfd | |
parent | 68e52bc7ecfbfdc8d5f85716a8ac7668e211f360 (diff) | |
download | gdb-327ef784ba105f067f5c1d587908259d7aabb971.zip gdb-327ef784ba105f067f5c1d587908259d7aabb971.tar.gz gdb-327ef784ba105f067f5c1d587908259d7aabb971.tar.bz2 |
Replace a couple of assertions in the BFD library that can be triggered by attempts to parse corrupt input files.
PR 25633
* elf.c (_bfd_elf_copy_special_section_fields): Replace assertions
with error messages.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf.c | 28 |
2 files changed, 29 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 515ab02..461ce20 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2020-03-17 Nick Clifton <nickc@redhat.com> + PR 25633 + * elf.c (_bfd_elf_copy_special_section_fields): Replace assertions + with error messages. + +2020-03-17 Nick Clifton <nickc@redhat.com> + PR 25687 * elf.c (_bfd_elf_slurp_secondary_reloc_section): Remove redundant free. Add free on another failure path. @@ -12592,13 +12592,31 @@ _bfd_elf_copy_special_section_fields (const bfd * ibfd ATTRIBUTE_UNUSED, } /* Find the output section that corresponds to the isection's sh_info link. */ - BFD_ASSERT (isection->sh_info > 0 - && isection->sh_info < elf_numsections (ibfd)); + if (isection->sh_info == 0 + || isection->sh_info >= elf_numsections (ibfd)) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%pA): info section index is invalid"), + obfd, osec); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + isection = elf_elfsections (ibfd)[isection->sh_info]; - BFD_ASSERT (isection != NULL); - BFD_ASSERT (isection->bfd_section != NULL); - BFD_ASSERT (isection->bfd_section->output_section != NULL); + if (isection == NULL + || isection->bfd_section == NULL + || isection->bfd_section->output_section == NULL) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%pA): info section index cannot be set because the section is not in the output"), + obfd, osec); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + osection->sh_info = elf_section_data (isection->bfd_section->output_section)->this_idx; |