From 9fb39ec8d5d122e4eaa82a02c48d6e6cdbaf4afd Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Mon, 9 Sep 2002 19:53:24 +0000 Subject: [PATCH] Fixing #1149: Truncate files used for editing messages. --- editmsg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/editmsg.c b/editmsg.c index bf9d17c4..c105a48e 100644 --- a/editmsg.c +++ b/editmsg.c @@ -88,6 +88,21 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur) if (stat (tmp, &sb) == 0) mtime = sb.st_mtime; + /* + * 2002-09-05 me@sigpipe.org + * The file the user is going to edit is not a real mbox, so we need to + * truncate the last newline in the temp file, which is logically part of + * the message separator, and not the body of the message. If we fail to + * remove it, the message will grow by one line each time the user edits + * the message. + */ + if (sb.st_size != 0 && truncate (tmp, sb.st_size - 1) == -1) + { + mutt_error (_("could not truncate temporary mail folder: %s"), + strerror (errno)); + goto bail; + } + mutt_edit_file (NONULL(Editor), tmp); if ((rc = stat (tmp, &sb)) == -1) -- 2.40.0