public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* readelf: ubsan: shift exponent 32 is too large
@ 2020-08-30 13:20 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-08-30 13:20 UTC (permalink / raw)
  To: binutils

When compiled on a 32-bit host, a temp var is too small for possible
64-bit values to be calculated.

	* readelf.c (print_gnu_build_attribute_name): Make "bytes"
	unsigned long long.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index f02848e468..94aa876b5a 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19662,7 +19662,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
 
 	while (bytes --)
 	  {
-	    unsigned long byte = (* name ++) & 0xff;
+	    unsigned long long byte = *name++ & 0xff;
 
 	    val |= byte << shift;
 	    shift += 8;

-- 
Alan Modra
Australia Development Lab, IBM

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

only message in thread, other threads:[~2020-08-30 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 13:20 readelf: ubsan: shift exponent 32 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).