From bbba3d4ed2752f18c4d33d89a8e8cdf7c3df8737 Mon Sep 17 00:00:00 2001 From: Vincent Lefevre <vincent@vinc17.org> Date: Tue, 15 Mar 2016 18:01:44 -0700 Subject: [PATCH] Check return value of ftruncate() in mbox_sync_mailbox(). Generate an error in the event that ftruncate() fails. --- mbox.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mbox.c b/mbox.c index cdc810994..870da6aaa 100644 --- 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")); + } } } -- 2.40.0