From 7fbd5f4e2c143bbe28715608ca00e2e93a7d7fd4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 17 Dec 2020 23:21:11 +1030 Subject: 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. --- bfd/vms-alpha.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bfd/vms-alpha.c') diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 471e021..4fb2945 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -2927,6 +2927,7 @@ static void _bfd_vms_write_emh (bfd *abfd) { struct vms_rec_wr *recwr = &PRIV (recwr); + unsigned char tbuf[18]; _bfd_vms_output_alignment (recwr, 2); @@ -2949,7 +2950,7 @@ _bfd_vms_write_emh (bfd *abfd) _bfd_vms_output_counted (recwr, "NONAME"); _bfd_vms_output_counted (recwr, BFD_VERSION_STRING); - _bfd_vms_output_dump (recwr, get_vms_time_string (), EMH_DATE_LENGTH); + _bfd_vms_output_dump (recwr, get_vms_time_string (tbuf), EMH_DATE_LENGTH); _bfd_vms_output_fill (recwr, 0, EMH_DATE_LENGTH); _bfd_vms_output_end (abfd, recwr); } -- cgit v1.1