aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2014-03-14 12:56:12 -0400
committerAnthony Green <green@moxielogic.com>2014-03-14 12:56:12 -0400
commit182a105a387c08da7daaba548d84bc42f73edd87 (patch)
treee8596a2568ced74bc5b493c67a0196cc6f8ccac3
parent8d052926671eb0e8c83ffab6d15a98790c215a36 (diff)
downloadfsf-binutils-gdb-182a105a387c08da7daaba548d84bc42f73edd87.zip
fsf-binutils-gdb-182a105a387c08da7daaba548d84bc42f73edd87.tar.gz
fsf-binutils-gdb-182a105a387c08da7daaba548d84bc42f73edd87.tar.bz2
Check fwrite return code
-rw-r--r--binutils/ChangeLog4
-rw-r--r--binutils/objcopy.c7
2 files changed, 10 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index e4280bb..bf8d150 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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 ...
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index cb2be49..6215919 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -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"));