]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libbacktrace: add cast to avoid undefined shift
authorIan Lance Taylor <iant@golang.org>
Mon, 10 Feb 2025 23:03:31 +0000 (15:03 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 10 Feb 2025 23:03:31 +0000 (15:03 -0800)
Patch from pgerell@github.

* elf.c (elf_uncompress_lzma_block): Add casts to avoid
potentially shifting a value farther than its type size.

libbacktrace/elf.c

index d766fa41a61c3f16e893ce094c5157044728b48b..868d0e1a7f3e52e550f21ee9c5f68c8eed7db575 100644 (file)
@@ -5878,7 +5878,7 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
          /* The byte at compressed[off] is ignored for some
             reason.  */
 
-         code = ((uint32_t)(compressed[off + 1] << 24)
+         code = (((uint32_t)compressed[off + 1] << 24)
                  + ((uint32_t)compressed[off + 2] << 16)
                  + ((uint32_t)compressed[off + 3] << 8)
                  + (uint32_t)compressed[off + 4]);