Skip to content

Commit

Permalink
libbacktrace: add cast to avoid undefined shift
Browse files Browse the repository at this point in the history
Patch from pgerell@github.

	* elf.c (elf_uncompress_lzma_block): Add casts to avoid
	potentially shifting a value farther than its type size.
  • Loading branch information
ianlancetaylor committed Feb 10, 2025
1 parent 78af4ff commit 0034e33
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 0034e33

Please sign in to comment.