diff options
author | Alan Modra <amodra@gmail.com> | 2020-12-17 23:21:11 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-12-18 10:34:16 +1030 |
commit | 7fbd5f4e2c143bbe28715608ca00e2e93a7d7fd4 (patch) | |
tree | f6bc1211e0cdaecc93850eae7a46b305632c0035 /bfd/elf32-rx.c | |
parent | bd38246a45dc199ce32b50878670bbbdf7e27ad5 (diff) | |
download | binutils-7fbd5f4e2c143bbe28715608ca00e2e93a7d7fd4.zip binutils-7fbd5f4e2c143bbe28715608ca00e2e93a7d7fd4.tar.gz binutils-7fbd5f4e2c143bbe28715608ca00e2e93a7d7fd4.tar.bz2 |
Remove some static buffers
Fixes possible overflow of a static buffer for powerpc with translated
messages, and on v850 when symbol names are large.
* archive.c (_bfd_ar_spacepad, _bfd_ar_sizepad): Use auto buf.
* coff-mcore.c (coff_mcore_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_unhandled_reloc): Use asprintf in place
of fixed size and possibly too small buf for translated message.
* elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* ecoff.c (ecoff_type_to_string): Pass in return string buff rather
than using static buffer2. Delete dead code. Remove unnecessary
parentheses.
(_bfd_ecoff_print_symbol): Pass auto buff to ecoff_type_to_string.
* elf32-rx.c (describe_flags): Pass in return string buf rather
than using static buf.
(rx_elf_merge_private_bfd_data): Pass buf to describe_flags.
(rx_elf_print_private_bfd_data): Likewise.
* mach-o.c (cpusubtype): Pass in return string buffer rather than
using static buffer.
(bfd_mach_o_bfd_print_private_bfd_data): Pass buff to cpusubtype.
* opncls.c (separate_debug_file_exists): Make buffer an auto var.
(bfd_fill_in_gnu_debuglink_section): Likewise.
* peXXigen.c (rsrc_resource_name): Pass in return string buffer
rather than using static buffer.
(rsrc_sort_entries): Pass buff to rsrc_resource_name.
* vms-alpha.c (_bfd_vms_write_emh): Pass tbuf to get_vms_time_string.
* vms-misc.c (get_vms_time_string): Pass in return string tbuf
rather than using static tbuf.
* vms.h (get_vms_time_string): Update prototype.
Diffstat (limited to 'bfd/elf32-rx.c')
-rw-r--r-- | bfd/elf32-rx.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 3f03ab2..cd239bf 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -3086,10 +3086,8 @@ bfd_elf32_rx_set_target_flags (bfd_boolean user_no_warn_mismatch, Returns a static pointer. */ static const char * -describe_flags (flagword flags) +describe_flags (flagword flags, char *buf) { - static char buf [128]; - buf[0] = 0; if (flags & E_FLAG_RX_64BIT_DOUBLES) @@ -3170,13 +3168,15 @@ rx_elf_merge_private_bfd_data (bfd * ibfd, struct bfd_link_info *info) } else { + char buf[128]; + _bfd_error_handler (_("there is a conflict merging the" " ELF header flags from %pB"), ibfd); _bfd_error_handler (_(" the input file's flags: %s"), - describe_flags (new_flags)); + describe_flags (new_flags, buf)); _bfd_error_handler (_(" the output file's flags: %s"), - describe_flags (old_flags)); + describe_flags (old_flags, buf)); error = TRUE; } } @@ -3195,6 +3195,7 @@ rx_elf_print_private_bfd_data (bfd * abfd, void * ptr) { FILE * file = (FILE *) ptr; flagword flags; + char buf[128]; BFD_ASSERT (abfd != NULL && ptr != NULL); @@ -3204,7 +3205,7 @@ rx_elf_print_private_bfd_data (bfd * abfd, void * ptr) flags = elf_elfheader (abfd)->e_flags; fprintf (file, _("private flags = 0x%lx:"), (long) flags); - fprintf (file, "%s", describe_flags (flags)); + fprintf (file, "%s", describe_flags (flags, buf)); return TRUE; } |