From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: ubsan: bfd_mach_o_build_commands shift exponent 64 is too large
Date: Sat, 1 Jan 2022 15:48:41 +1030 [thread overview]
Message-ID: <Yc/kMczKMXWJA9nV@squeak.grove.modra.org> (raw)
* mach-o.c (bfd_mach_o_read_section_32): Limit alignment further.
(bfd_mach_o_read_section_64): Likewise.
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index d90ea3c28ce..af5ce024a0f 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3653,12 +3653,12 @@ bfd_mach_o_read_section_32 (bfd *abfd, unsigned long prot)
section->offset = bfd_h_get_32 (abfd, raw.offset);
section->align = bfd_h_get_32 (abfd, raw.align);
/* PR 17512: file: 0017eb76. */
- if (section->align > 64)
+ if (section->align >= 31)
{
_bfd_error_handler
- (_("bfd_mach_o_read_section_32: overlarge alignment value: %#lx, "
- "using 32 instead"), section->align);
- section->align = 32;
+ (_("bfd_mach_o_read_section_32: overlarge alignment value: %#lx"),
+ section->align);
+ section->align = 30;
}
section->reloff = bfd_h_get_32 (abfd, raw.reloff);
section->nreloc = bfd_h_get_32 (abfd, raw.nreloc);
@@ -3696,12 +3696,12 @@ bfd_mach_o_read_section_64 (bfd *abfd, unsigned long prot)
section->size = bfd_h_get_64 (abfd, raw.size);
section->offset = bfd_h_get_32 (abfd, raw.offset);
section->align = bfd_h_get_32 (abfd, raw.align);
- if (section->align > 64)
+ if (section->align >= 63)
{
_bfd_error_handler
- (_("bfd_mach_o_read_section_64: overlarge alignment value: %#lx, "
- "using 32 instead"), section->align);
- section->align = 32;
+ (_("bfd_mach_o_read_section_64: overlarge alignment value: %#lx"),
+ section->align);
+ section->align = 62;
}
section->reloff = bfd_h_get_32 (abfd, raw.reloff);
section->nreloc = bfd_h_get_32 (abfd, raw.nreloc);
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-01-01 5:18 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=Yc/kMczKMXWJA9nV@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).