mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 16:05:56 +08:00
bfd: Avoid signed overflow for new_size adjustment
When bfd_size_type is unsigned 64-bit integer and sizeof is unsigned 32-bit integer, subtraction in *new_size += sizeof (Elf32_External_Chdr) - sizeof (Elf64_External_Chdr); will overflow. Use *new_size -= sizeof (Elf64_External_Chdr) - sizeof (Elf32_External_Chdr); to avoid overflow. PR binutils/29860 * compress.c (bfd_convert_section_setup): Avoid signed overflow for new_size adjustment.
This commit is contained in:
@ -306,7 +306,7 @@ bfd_convert_section_setup (bfd *ibfd, asection *isec, bfd *obfd,
|
||||
if (hdr_size == sizeof (Elf32_External_Chdr))
|
||||
*new_size += sizeof (Elf64_External_Chdr) - sizeof (Elf32_External_Chdr);
|
||||
else
|
||||
*new_size += sizeof (Elf32_External_Chdr) - sizeof (Elf64_External_Chdr);
|
||||
*new_size -= sizeof (Elf64_External_Chdr) - sizeof (Elf32_External_Chdr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user