public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] asan: uninitialised write in bfd_mach_o_write_contents
@ 2022-06-04 11:28 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-06-04 11:28 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=21aacea42ecaa7aca9b686e8de0f79a1f4e7d668
commit 21aacea42ecaa7aca9b686e8de0f79a1f4e7d668
Author: Alan Modra <amodra@gmail.com>
Date: Sat Jun 4 18:31:54 2022 +0930
asan: uninitialised write in bfd_mach_o_write_contents
* mach-o.c (bfd_mach_o_write_contents): Always set
bfd_mach_o_dyld_info_command *_off fields.
Diff:
---
bfd/mach-o.c | 35 ++++++++++-------------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 9f3f1f13e4e..c761544e21e 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -2656,31 +2656,16 @@ bfd_mach_o_write_contents (bfd *abfd)
{
bfd_mach_o_dyld_info_command *di = &cmd->command.dyld_info;
- if (di->rebase_size != 0)
- {
- di->rebase_off = mdata->filelen;
- mdata->filelen += di->rebase_size;
- }
- if (di->bind_size != 0)
- {
- di->bind_off = mdata->filelen;
- mdata->filelen += di->bind_size;
- }
- if (di->weak_bind_size != 0)
- {
- di->weak_bind_off = mdata->filelen;
- mdata->filelen += di->weak_bind_size;
- }
- if (di->lazy_bind_size != 0)
- {
- di->lazy_bind_off = mdata->filelen;
- mdata->filelen += di->lazy_bind_size;
- }
- if (di->export_size != 0)
- {
- di->export_off = mdata->filelen;
- mdata->filelen += di->export_size;
- }
+ di->rebase_off = di->rebase_size != 0 ? mdata->filelen : 0;
+ mdata->filelen += di->rebase_size;
+ di->bind_off = di->bind_size != 0 ? mdata->filelen : 0;
+ mdata->filelen += di->bind_size;
+ di->weak_bind_off = di->weak_bind_size != 0 ? mdata->filelen : 0;
+ mdata->filelen += di->weak_bind_size;
+ di->lazy_bind_off = di->lazy_bind_size != 0 ? mdata->filelen : 0;
+ mdata->filelen += di->lazy_bind_size;
+ di->export_off = di->export_size != 0 ? mdata->filelen : 0;
+ mdata->filelen += di->export_size;
}
break;
case BFD_MACH_O_LC_LOAD_DYLIB:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-04 11:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04 11:28 [binutils-gdb] asan: uninitialised write in bfd_mach_o_write_contents 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).