]> granicus.if.org Git - mutt/commitdiff
Do more error checking when writing messages to folders.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 17 Feb 2000 18:00:38 +0000 (18:00 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 17 Feb 2000 18:00:38 +0000 (18:00 +0000)
attach.c
mx.c
pop.c
sendlib.c

index 8b2d668f9c30bf34c4749b1538ec8b94b8826b93..fb1ecee129ef5387e80b1e2880ae9d1d56ca0882 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -702,10 +702,12 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
       if (ctx.magic == M_MBOX || ctx.magic == M_MMDF || ctx.magic == M_KENDRA)
        chflags = CH_FROM;
       chflags |= (ctx.magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
-      if ((r = _mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags)) == 0)
+      if (_mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags) == 0 
+         && mx_commit_message (msg, &ctx) == 0)
        mutt_message _("Attachment saved.");
+      else
+       r = -1;
 
-      mx_commit_message (msg, &ctx);
       mx_close_message (&msg);
       mx_close_mailbox (&ctx);
       return r;
diff --git a/mx.c b/mx.c
index 5ad4255e5ece7ec5a9c4b52c5f02c9bdee703c13..1b6e98e5e76e373535ebc12f376876150c40df33 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1331,19 +1331,22 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
   {
     case M_MMDF:
     {
-      fputs (MMDF_SEP, msg->fp);
+      if (fputs (MMDF_SEP, msg->fp) == EOF)
+       r = -1;
       break;
     }
     
     case M_MBOX:
     {
-      fputc ('\n', msg->fp);
+      if (fputc ('\n', msg->fp) == EOF)
+       r = -1;
       break;
     }
 
     case M_KENDRA:
     {
-      fputs (KENDRA_SEP, msg->fp);
+      if (fputs (KENDRA_SEP, msg->fp) == EOF)
+       r = -1;
       break;
     }
 
@@ -1370,6 +1373,14 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
       break;
     }
   }
+  
+  if (r == 0 && (ctx->magic == M_MBOX || ctx->magic == M_MMDF || ctx->magic == M_KENDRA)
+      && fflush (msg->fp) == EOF)
+  {
+    mutt_perror _("Can't write message");
+    r = -1;
+  }
   return r;
 }
 
diff --git a/pop.c b/pop.c
index f2f8c00ebcee7a5f0972f4db7453ef21e6744e65..e8da4a9c5138f85745f3811a3c45940336ed867d 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -313,7 +313,8 @@ void mutt_fetchPopMail (void)
 
   if (msg)
   {
-    mx_commit_message (msg, &ctx);
+    if (mx_commit_message (msg, &ctx) != 0)
+      err = 1;
     mx_close_message (&msg);
   }
   mx_close_mailbox (&ctx);
index f61807917f4b7de4b8e5759fc784946ed4a72c2b..25acc4de3d975bbe3c41e49c78703b0f85d8a7c8 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2082,7 +2082,8 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
     r = mutt_write_mime_body (hdr->content, msg->fp);
   }
 
-  mx_commit_message (msg, &f);
+  if (mx_commit_message (msg, &f) != 0)
+    r = -1;
   mx_close_message (&msg);
   mx_close_mailbox (&f);