public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: undefined shift in mach-o.c
@ 2021-11-06 10:52 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2021-11-06 10:52 UTC (permalink / raw)
  To: binutils

This one was logically wrong too.  If file_ptr was 64 bits, then -1U
is extended to 0x00000000ffffffff, probably not what was intended
here.

	* mach-o.c (FILE_ALIGN): Correct expression.

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 1f0d4700811..d90ea3c28ce 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -36,7 +36,7 @@
 #define bfd_mach_o_mkobject bfd_mach_o_gen_mkobject
 
 #define FILE_ALIGN(off, algn) \
-  (((off) + ((file_ptr) 1 << (algn)) - 1) & ((file_ptr) -1U << (algn)))
+  (((off) + ((ufile_ptr) 1 << (algn)) - 1) & ((ufile_ptr) -1 << (algn)))
 
 static bool
 bfd_mach_o_read_dyld_content (bfd *abfd, bfd_mach_o_dyld_info_command *cmd);

-- 
Alan Modra
Australia Development Lab, IBM

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

only message in thread, other threads:[~2021-11-06 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 10:52 ubsan: undefined shift in mach-o.c 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).