public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: undefined shift in frag_align_code
@ 2022-06-02  7:38 Alan Modra
  2022-06-03 13:23 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2022-06-02  7:38 UTC (permalink / raw)
  To: binutils

	* frags.c (MAX_MEM_FOR_RS_ALIGN_CODE): Avoid signed integer
	overflow.

diff --git a/gas/frags.c b/gas/frags.c
index f5afe1a49b5..8e88496f37c 100644
--- a/gas/frags.c
+++ b/gas/frags.c
@@ -367,7 +367,7 @@ frag_align_pattern (int alignment, const char *fill_pattern,
 # ifndef HANDLE_ALIGN
 #  define MAX_MEM_FOR_RS_ALIGN_CODE  1
 # else
-#  define MAX_MEM_FOR_RS_ALIGN_CODE  ((1 << alignment) - 1)
+#  define MAX_MEM_FOR_RS_ALIGN_CODE  (((size_t) 1 << alignment) - 1)
 # endif
 #endif
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-03 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  7:38 ubsan: undefined shift in frag_align_code Alan Modra
2022-06-03 13:23 ` 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).