readelf: ubsan: shift exponent 32 is too large

Alan Modra amodra@gmail.com
Sun Aug 30 13:20:10 GMT 2020


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


More information about the Binutils mailing list