]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-show.c
show: Handle read and write errors
[notmuch] / notmuch-show.c
index d14dac976e33d596565721fcd3616e8f12c814f4..c674e2506ff73270f4e43cd3937078ad3aa1b38b 100644 (file)
@@ -883,7 +883,17 @@ do_show_single (void *ctx,
 
        while (!feof (file)) {
            size = fread (buf, 1, sizeof (buf), file);
-           (void) fwrite (buf, size, 1, stdout);
+           if (ferror (file)) {
+               fprintf (stderr, "Error: Read failed from %s\n", filename);
+               fclose (file);
+               return 1;
+           }
+
+           if (fwrite (buf, size, 1, stdout) != 1) {
+               fprintf (stderr, "Error: Write failed\n");
+               fclose (file);
+               return 1;
+           }
        }
 
        fclose (file);