objcopy fuzzed pe out of memory
authorAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 12:30:12 +0000 (23:00 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 13:22:26 +0000 (23:52 +1030)
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.

binutils/objcopy.c

index 4d888906e6784f13a94fcb387a9cceef0c314c0a..80a5d52e227d001c8934697ce8aceb762a22e05b 100644 (file)
@@ -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)
     {