public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] objcopy fuzzed pe out of memory
@ 2023-01-04 13:32 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-01-04 13:32 UTC (permalink / raw)
  To: bfd-cvs

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)
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-04 13:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 13:32 [binutils-gdb] objcopy fuzzed pe out of memory Alan Modra

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).