mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-02 19:46:09 +08:00
PR22443, Global buffer overflow in _bfd_elf_get_symbol_version_string
Symbols like *ABS* defined in bfd/section.c:global_syms are not elf_symbol_type. They can appear on relocs and perhaps other places in an ELF bfd, so a number of places in nm.c and objdump.c are wrong to cast an asymbol based on the bfd being ELF. I think we lose nothing by excluding all section symbols, not just the global_syms. PR 22443 * nm.c (sort_symbols_by_size): Don't attempt to access section symbol internal_elf_sym. (print_symbol): Likewise. Don't call bfd_get_symbol_version_string for section symbols. * objdump.c (compare_symbols): Don't attempt to access section symbol internal_elf_sym. (objdump_print_symname): Don't call bfd_get_symbol_version_string for section symbols.
This commit is contained in:
@ -799,10 +799,10 @@ compare_symbols (const void *ap, const void *bp)
|
||||
bfd_vma asz, bsz;
|
||||
|
||||
asz = 0;
|
||||
if ((a->flags & BSF_SYNTHETIC) == 0)
|
||||
if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
|
||||
asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size;
|
||||
bsz = 0;
|
||||
if ((b->flags & BSF_SYNTHETIC) == 0)
|
||||
if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
|
||||
bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size;
|
||||
if (asz != bsz)
|
||||
return asz > bsz ? -1 : 1;
|
||||
@ -888,7 +888,7 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
|
||||
name = alloc;
|
||||
}
|
||||
|
||||
if ((sym->flags & BSF_SYNTHETIC) == 0)
|
||||
if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
|
||||
version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
|
||||
|
||||
if (bfd_is_und_section (bfd_get_section (sym)))
|
||||
|
Reference in New Issue
Block a user