public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] PR24955, libbfd terminating program on out of memory (part2) Date: Sat, 19 Oct 2019 02:13:00 -0000 [thread overview] Message-ID: <ec9bd0a22dd42327ae9943937a96f1e865fb5d46@gdb-build> (raw) *** TEST RESULTS FOR COMMIT ec9bd0a22dd42327ae9943937a96f1e865fb5d46 *** commit ec9bd0a22dd42327ae9943937a96f1e865fb5d46 Author: Alan Modra <amodra@gmail.com> AuthorDate: Mon Oct 14 13:34:30 2019 +1030 Commit: Alan Modra <amodra@gmail.com> CommitDate: Mon Oct 14 16:47:12 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. diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 56f38cfb03..a864b8beb3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,14 @@ +2019-10-14 Alan Modra <amodra@gmail.com> + + 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. + 2019-10-11 Max Filippov <jcmvbkbc@gmail.com> * dwarf2.c (stash_maybe_enable_info_hash_tables): Only set diff --git a/bfd/elflink.c b/bfd/elflink.c index 395d96d6cf..d0f70cb6f5 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11649,7 +11649,10 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info) return FALSE; /* Read in the symbol table. */ - sympp = (asymbol **) xmalloc (symsize); + sympp = (asymbol **) bfd_malloc (symsize); + if (sympp == NULL) + return FALSE; + symcount = bfd_canonicalize_symtab (abfd, sympp); if (symcount < 0) goto free_sym_buf; @@ -11677,6 +11680,9 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info) /* Make symbols absolute. */ osymbuf = (elf_symbol_type *) bfd_alloc2 (implib_bfd, symcount, sizeof (*osymbuf)); + if (osymbuf == NULL) + goto free_sym_buf; + for (src_count = 0; src_count < symcount; src_count++) { memcpy (&osymbuf[src_count], (elf_symbol_type *) sympp[src_count], diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index ee6da6480d..ab0da7f532 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -1216,7 +1216,10 @@ _bfd_XXi_write_codeview_record (bfd * abfd, file_ptr where, CODEVIEW_INFO *cvinf if (bfd_seek (abfd, where, SEEK_SET) != 0) return 0; - buffer = xmalloc (size); + buffer = bfd_malloc (size); + if (buffer == NULL) + return 0; + cvinfo70 = (CV_INFO_PDB70 *) buffer; H_PUT_32 (abfd, CVINFO_PDB70_CVSIGNATURE, cvinfo70->CvSignature); diff --git a/bfd/pef.c b/bfd/pef.c index effa076405..fccb9b6ac3 100644 --- a/bfd/pef.c +++ b/bfd/pef.c @@ -221,15 +221,16 @@ bfd_pef_print_symbol (bfd *abfd, fprintf (file, " %-5s %s", symbol->section->name, symbol->name); if (CONST_STRNEQ (symbol->name, "__traceback_")) { - unsigned char *buf = xmalloc (symbol->udata.i); + unsigned char *buf; size_t offset = symbol->value + 4; size_t len = symbol->udata.i; - int ret; - bfd_get_section_contents (abfd, symbol->section, buf, offset, len); - ret = bfd_pef_parse_traceback_table (abfd, symbol->section, buf, - len, 0, NULL, file); - if (ret < 0) + buf = bfd_malloc (len); + if (buf == NULL + || !bfd_get_section_contents (abfd, symbol->section, buf, + offset, len) + || bfd_pef_parse_traceback_table (abfd, symbol->section, buf, + len, 0, NULL, file) < 0) fprintf (file, " [ERROR]"); free (buf); } diff --git a/bfd/som.c b/bfd/som.c index 4c9dcaee67..5145651c3d 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -3309,13 +3309,16 @@ som_write_space_strings (bfd *abfd, /* Chunk of memory that we can use as buffer space, then throw away. */ size_t tmp_space_size = SOM_TMP_BUFSIZE; - char *tmp_space = xmalloc (tmp_space_size); + char *tmp_space = bfd_malloc (tmp_space_size); char *p = tmp_space; unsigned int strings_size = 0; asection *section; bfd_size_type amt; bfd_size_type res; + if (tmp_space == NULL) + return FALSE; + /* Seek to the start of the space strings in preparation for writing them out. */ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) @@ -3419,12 +3422,15 @@ som_write_symbol_strings (bfd *abfd, /* Chunk of memory that we can use as buffer space, then throw away. */ size_t tmp_space_size = SOM_TMP_BUFSIZE; - char *tmp_space = xmalloc (tmp_space_size); + char *tmp_space = bfd_malloc (tmp_space_size); char *p = tmp_space; unsigned int strings_size = 0; bfd_size_type amt; bfd_size_type res; + if (tmp_space == NULL) + return FALSE; + /* This gets a bit gruesome because of the compilation unit. The strings within the compilation unit are part of the symbol strings, but don't have symbol_dictionary entries. So, manually
next reply other threads:[~2019-10-19 2:13 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-10-19 2:13 gdb-buildbot [this message] 2019-10-19 2:13 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot 2019-10-19 3:45 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot 2019-10-19 4:35 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot 2019-10-26 18:38 ` Failures on Fedora-i686, " gdb-buildbot 2019-10-26 19:17 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot 2019-10-26 19:57 ` Failures on Fedora-x86_64-m32, " gdb-buildbot 2019-10-26 20:22 ` Failures on Fedora-x86_64-m64, " gdb-buildbot 2019-10-26 20:38 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot 2019-10-26 21:06 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ec9bd0a22dd42327ae9943937a96f1e865fb5d46@gdb-build \ --to=gdb-buildbot@sergiodj.net \ --cc=gdb-testers@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).