readelf: ubsan: shift exponent 32 is too large
authorAlan Modra <amodra@gmail.com>
Sun, 30 Aug 2020 10:57:27 +0000 (20:27 +0930)
committerAlan Modra <amodra@gmail.com>
Sun, 30 Aug 2020 11:19:32 +0000 (20:49 +0930)
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.

binutils/ChangeLog
binutils/readelf.c

index ca9028688f9e017e79d389644845fe53cb8b1748..9872504871bd73dab3edd24b256190291c5dba96 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-30  Alan Modra  <amodra@gmail.com>
+
+       * readelf.c (print_gnu_build_attribute_name): Use unsigned long
+       long for "bytes".
+
 2020-08-28  Nick Clifton  <nickc@redhat.com>
 
        PR 26548
index f02848e4681707c4a1fee5fbc19070487ed5c7a9..94aa876b5aeb269d495255f6fa43549a5e35e29e 100644 (file)
@@ -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;