public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] objcopy fuzzed pe out of memory
Date: Wed,  4 Jan 2023 13:32:18 +0000 (GMT)	[thread overview]
Message-ID: <20230104133218.4479D3858C54@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fa19218f8b4ec6bc2d7da6b20dce5f2cd22072bd

commit fa19218f8b4ec6bc2d7da6b20dce5f2cd22072bd
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 4 23:00:12 2023 +1030

    objcopy fuzzed pe out of memory
    
    This occurs when attempting to read back a section from the output
    file in _bfd_XX_bfd_copy_private_bfd_data_common.  The copy of the
    section failed size sanity checking, thus it won't be written.
    
            * objcopy.c (copy_object): Return false if copy_section or
            copy_relocations_in_section fails.

Diff:
---
 binutils/objcopy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4d888906e67..80a5d52e227 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3328,9 +3328,13 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 
   /* This has to happen before section positions are set.  */
   bfd_map_over_sections (ibfd, copy_relocations_in_section, obfd);
+  if (status != 0)
+    return false;
 
   /* This has to happen after the symbol table has been set.  */
   bfd_map_over_sections (ibfd, copy_section, obfd);
+  if (status != 0)
+    return false;
 
   if (add_sections != NULL)
     {

                 reply	other threads:[~2023-01-04 13:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230104133218.4479D3858C54@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@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: link
Be 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).