[Bug libbacktrace/103167] UBSAN error since g:05f40bc4c116ba48843728201bc7290a5e518598

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 10 10:37:01 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103167

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #3)
> /home/mliska/Programming/binutils-gdb/libbacktrace/elf.c:3178:26: runtime
> error: left shift of 163 by 24 places cannot be represented in type 'int'

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 79d56146fc6..2cb25883975 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -3175,7 +3175,7 @@ elf_uncompress_lzma_block (const unsigned char
*compressed,
   stream_crc = (compressed[off]
                | (compressed[off + 1] << 8)
                | (compressed[off + 2] << 16)
-               | (compressed[off + 3] << 24));
+               | (((unsigned)compressed[off + 3]) << 24));
   if (unlikely (computed_crc != stream_crc))
     {
       elf_uncompress_failed ();


There is a few more in that file which are similar and needs the same.


More information about the Gcc-bugs mailing list