Check fwrite return code
authorAnthony Green <green@moxielogic.com>
Fri, 14 Mar 2014 16:56:12 +0000 (12:56 -0400)
committerAnthony Green <green@moxielogic.com>
Fri, 14 Mar 2014 16:56:12 +0000 (12:56 -0400)
binutils/ChangeLog
binutils/objcopy.c

index e4280bb323035d76b91b6f22d7df21cea58aec4d..bf8d15091d0bad3381ea812ce6c056c915afc2ff 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-14  Anthony Green  <green@moxielogic.com>
+
+       * objcopy.c (copy_object): Check fwrite return code.
+
 2014-03-14  Meador Inge  <meadori@codesourcery.com>
 
          * dwarf.c (strnlen): Move prototype ...
index cb2be497b837b97b17ff1a81a587ca7a58c708e5..6215919bb7cc7efab67afeb0bc45b29bc841c6f4 100644 (file)
@@ -1875,7 +1875,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 
          bfd_byte * contents = xmalloc (size);
          if (bfd_get_section_contents (ibfd, sec, contents, 0, size))
-           fwrite (contents, 1, size, f);
+           {
+             if (fwrite (contents, 1, size, f) != size)
+               fatal (_("error writing section contents to %s (error: %s)"),
+                      pdump->filename,
+                      strerror (errno));
+           }
          else
            bfd_nonfatal_message (NULL, ibfd, sec,
                                  _("could not retrieve section contents"));