From 41ac4a02bd17781e738a97f1ab6fedeadc7015c8 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Thu, 17 Feb 2000 18:00:38 +0000 Subject: [PATCH] Do more error checking when writing messages to folders. --- attach.c | 6 ++++-- mx.c | 17 ++++++++++++++--- pop.c | 3 ++- sendlib.c | 3 ++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/attach.c b/attach.c index 8b2d668f..fb1ecee1 100644 --- 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 5ad4255e..1b6e98e5 100644 --- 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 f2f8c00e..e8da4a9c 100644 --- 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); diff --git a/sendlib.c b/sendlib.c index f6180791..25acc4de 100644 --- 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); -- 2.40.0