Summary: | libbfd terminating program on out of memory | ||
---|---|---|---|
Product: | binutils | Reporter: | Alan Modra <amodra> |
Component: | binutils | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | nickc |
Priority: | P2 | ||
Version: | 2.33 | ||
Target Milestone: | 2.34 | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Alan Modra
2019-09-02 02:44:52 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=89bdc77eabf5ede68322f6e47e003c1dc45b9ccb commit 89bdc77eabf5ede68322f6e47e003c1dc45b9ccb Author: Alan Modra <amodra@gmail.com> Date: Mon Sep 2 16:13:05 2019 +0930 PR24955, libbfd terminating program on out of memory This patch fixes the worst of the cases where libbfd might terminate a program due to calling xstrdup or xmalloc. I've also fixed some error paths that didn't clean up properly. PR 24955 * libbfd-in.h (bfd_strdup): New inline function. * archive.c (_bfd_get_elt_at_filepos): Use bfd_strdup. Close bfd on error. * elfcode.h (_bfd_elf_bfd_from_remote_memory): Use bfd_strdup. * opncls.c (bfd_fopen): Use bfd_strdup. Close fd and stream on error. (bfd_openstreamr): Use bfd_strdup. (bfd_openr_iovec, bfd_openw, bfd_create): Likewise. * plugin.c (try_load_plugin): Use bfd_malloc. * libbfd.h: Regenerate. The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ec9bd0a22dd42327ae9943937a96f1e865fb5d46 commit ec9bd0a22dd42327ae9943937a96f1e865fb5d46 Author: Alan Modra <amodra@gmail.com> Date: Mon Oct 14 13:34:30 2019 +1030 PR24955, libbfd terminating program on out of memory (part2) PR 24955 * elflink.c (elf_output_implib): Don't use xmalloc. Don't ignore return value of bfd_alloc2. * peXXigen.c (_bfd_XXi_write_codeview_record): Don't use xmalloc. * pef.c (bfd_pef_print_symbol): Likewise. Don't ignore return value of bfd_get_section_contents. * som.c (som_write_space_strings): Don't use xmalloc. (som_write_symbol_strings): Likewise. The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a73315161bc07d958060847ae01996312e1b30f commit 9a73315161bc07d958060847ae01996312e1b30f Author: Alan Modra <amodra@gmail.com> Date: Tue Oct 15 15:57:35 2019 +1030 remove more xmalloc in bfd Also fixes m68hc1x printf arguments which would have bombed when compiling on a 32-bit host with --enable-64-bit-bfd. bfd/ PR 24955 * elf32-arm.c (set_cmse_veneer_addr_from_implib): Use bfd_malloc rather than xmalloc. * elf32-m68hc1x.c (reloc_warning): New function. (elf32_m68hc11_relocate_section): Use it here. Cast bfd_vma values corresponding to %lx in format strings. * elf32-nds32.c (nds32_insertion_sort): Use a stack temporary. gas/ * config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n parameters rather than equivalent sec->orelocation and sec->reloc_count. Don't sort for n <= 1. Tidy. There are a few remaining target bfd files using xmalloc, but I'm declaring this bug fixed. |