[binutils-gdb] readelf: ubsan: shift exponent 32 is too large
Alan Modra
amodra@sourceware.org
Sun Aug 30 13:22:08 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=54b8331d0b6b58d6f7256a22e7a9457d64891a43
commit 54b8331d0b6b58d6f7256a22e7a9457d64891a43
Author: Alan Modra <amodra@gmail.com>
Date: Sun Aug 30 20:27:27 2020 +0930
readelf: ubsan: shift exponent 32 is too large
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:
---
binutils/ChangeLog | 5 +++++
binutils/readelf.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ca9028688f9..9872504871b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/readelf.c b/binutils/readelf.c
index f02848e4681..94aa876b5ae 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;
More information about the Binutils-cvs
mailing list