public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: bfd_mach_o_build_commands shift exponent 64 is too large
@ 2022-01-01  5:18 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-01-01  5:18 UTC (permalink / raw)
  To: binutils

	* 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-01  5:18 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:18 ubsan: bfd_mach_o_build_commands shift exponent 64 is too large 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).