* asan: Null-dereference in _bfd_xcoff_copy_private_bfd_data
@ 2022-01-01 5:17 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-01-01 5:17 UTC (permalink / raw)
To: binutils
sec->output_section will be NULL when objcopy removes sections.
* coff-rs6000.c (_bfd_xcoff_copy_private_bfd_data): Protect against
objcopy removing sections.
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 1cc2162e7d8..20b607403e4 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;
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-01 5:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-01 5:17 asan: Null-dereference in _bfd_xcoff_copy_private_bfd_data Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).