From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: NULL dereference read in som_write_object_contents
Date: Sat, 29 Oct 2022 15:22:19 +1030 [thread overview]
Message-ID: <Y1yxgzNJg5M48uPI@squeak.grove.modra.org> (raw)
objcopy copy_object may omit the call to bfd_copy_private_bfd_data for
various conditions deemed non-fatal, in which case obj_som_exec_data
will be NULL for the output file.
* som.c (som_finish_writing): Don't dereference NULL
obj_som_exec_data.
diff --git a/bfd/som.c b/bfd/som.c
index b3a72e36ede..7a5ee35f0e2 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -4211,7 +4211,7 @@ som_finish_writing (bfd *abfd)
/* Setting of the system_id has to happen very late now that copying of
BFD private data happens *after* section contents are set. */
- if (abfd->flags & (EXEC_P | DYNAMIC))
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) && obj_som_exec_data (abfd))
obj_som_file_hdr (abfd)->system_id = obj_som_exec_data (abfd)->system_id;
else if (bfd_get_mach (abfd) == pa20)
obj_som_file_hdr (abfd)->system_id = CPU_PA_RISC2_0;
@@ -4242,7 +4242,8 @@ som_finish_writing (bfd *abfd)
exec_header = obj_som_exec_hdr (abfd);
exec_header->exec_entry = bfd_get_start_address (abfd);
- exec_header->exec_flags = obj_som_exec_data (abfd)->exec_flags;
+ if (obj_som_exec_data (abfd))
+ exec_header->exec_flags = obj_som_exec_data (abfd)->exec_flags;
/* Oh joys. Ram some of the BSS data into the DATA section
to be compatible with how the hp linker makes objects
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-10-29 4:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1yxgzNJg5M48uPI@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).