From 54b8331d0b6b58d6f7256a22e7a9457d64891a43 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 30 Aug 2020 20:27:27 +0930 Subject: [PATCH] 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. --- 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 + + * readelf.c (print_gnu_build_attribute_name): Use unsigned long + long for "bytes". + 2020-08-28 Nick Clifton 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; -- 2.30.2