summaryrefslogtreecommitdiffstats
path: root/editmsg.c
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2002-09-09 19:53:24 +0000
committerMichael Elkins <me@sigpipe.org>2002-09-09 19:53:24 +0000
commit9fb39ec8d5d122e4eaa82a02c48d6e6cdbaf4afd (patch)
treef2de3f4b96cc459f1b4ae8fadca8aac58e9a2dea /editmsg.c
parent9786ef81a8c5fed02075ec51d1fbf8e15e8c215b (diff)
Fixing #1149: Truncate files used for editing messages.
Diffstat (limited to 'editmsg.c')
-rw-r--r--editmsg.c15
1 files changed, 15 insertions, 0 deletions
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)