diff options
author | Alan Modra <amodra@gmail.com> | 2022-01-01 13:52:38 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-01-01 14:22:11 +1030 |
commit | ad3d14c47e872fcd13d83c9a255266c7027c8e16 (patch) | |
tree | 15b0215ba2c33bc32cb160ef2ca1e6bf3cabca8d | |
parent | aebb3d543da4d411d3d767912193c3849f59ff99 (diff) | |
download | gdb-ad3d14c47e872fcd13d83c9a255266c7027c8e16.zip gdb-ad3d14c47e872fcd13d83c9a255266c7027c8e16.tar.gz gdb-ad3d14c47e872fcd13d83c9a255266c7027c8e16.tar.bz2 |
asan: Null-dereference in _bfd_xcoff_copy_private_bfd_data
sec->output_section will be NULL when objcopy removes sections.
* coff-rs6000.c (_bfd_xcoff_copy_private_bfd_data): Protect against
objcopy removing sections.
-rw-r--r-- | bfd/coff-rs6000.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 1cc2162..20b6074 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -386,7 +386,7 @@ _bfd_xcoff_copy_private_bfd_data (bfd *ibfd, bfd *obfd) else { sec = coff_section_from_bfd_index (ibfd, ix->sntoc); - if (sec == NULL) + if (sec == NULL || sec->output_section == NULL) ox->sntoc = 0; else ox->sntoc = sec->output_section->target_index; @@ -396,7 +396,7 @@ _bfd_xcoff_copy_private_bfd_data (bfd *ibfd, bfd *obfd) else { sec = coff_section_from_bfd_index (ibfd, ix->snentry); - if (sec == NULL) + if (sec == NULL || sec->output_section == NULL) ox->snentry = 0; else ox->snentry = sec->output_section->target_index; |