diff options
author | Alan Modra <amodra@gmail.com> | 2021-12-17 13:02:55 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-12-17 16:01:17 +1030 |
commit | b39de8897a9a3de9a1146c020be29e0742dad747 (patch) | |
tree | 677a8a62f2e1e50429ab68115a2494a851052af3 | |
parent | 00d44f7f2f513c56a784a6d418833bb3da8a188f (diff) | |
download | gdb-b39de8897a9a3de9a1146c020be29e0742dad747.zip gdb-b39de8897a9a3de9a1146c020be29e0742dad747.tar.gz gdb-b39de8897a9a3de9a1146c020be29e0742dad747.tar.bz2 |
ubsan: bfd.c:2519:8: shift exponent 34 is too large
* bfd.c (bfd_update_compression_header): Avoid integer overflow.
-rw-r--r-- | bfd/bfd.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2504,7 +2504,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) contents; bfd_put_32 (abfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); bfd_put_32 (abfd, sec->size, &echdr->ch_size); - bfd_put_32 (abfd, 1 << sec->alignment_power, + bfd_put_32 (abfd, 1u << sec->alignment_power, &echdr->ch_addralign); /* bfd_log2 (alignof (Elf32_Chdr)) */ bfd_set_section_alignment (sec, 2); @@ -2516,7 +2516,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, bfd_put_32 (abfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); bfd_put_32 (abfd, 0, &echdr->ch_reserved); bfd_put_64 (abfd, sec->size, &echdr->ch_size); - bfd_put_64 (abfd, 1 << sec->alignment_power, + bfd_put_64 (abfd, UINT64_C (1) << sec->alignment_power, &echdr->ch_addralign); /* bfd_log2 (alignof (Elf64_Chdr)) */ bfd_set_section_alignment (sec, 3); |