]> granicus.if.org Git - neomutt/commitdiff
Check return value of ftruncate() in mbox_sync_mailbox().
authorVincent Lefevre <vincent@vinc17.org>
Wed, 16 Mar 2016 01:01:44 +0000 (18:01 -0700)
committerVincent Lefevre <vincent@vinc17.org>
Wed, 16 Mar 2016 01:01:44 +0000 (18:01 -0700)
Generate an error in the event that ftruncate() fails.

mbox.c

diff --git a/mbox.c b/mbox.c
index cdc810994398be41afabc4395e2008cb6fcadba7..870da6aaa8fc49d9abff26891aecd634e8d8237c 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -968,7 +968,11 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     if (i == 0)
     {
       ctx->size = ftello (ctx->fp); /* update the size of the mailbox */
-      ftruncate (fileno (ctx->fp), ctx->size);
+      if (ftruncate (fileno (ctx->fp), ctx->size) != 0)
+      {
+        i = -1;
+        dprint (1, (debugfile, "mbox_sync_mailbox: ftruncate() failed\n"));
+      }
     }
   }