Skip to content

Commit 239ff6d

Browse files
Alexey Sukhoguzovcorecode
authored andcommitted
Terminate each local message by an empty line
According to RFC 4155, each message in the mbox database must be terminated by an empty line, containing a single end-of-line marker. That doesn't match the current behavior, where dma writes this EOL marker at the same time with the following separator line on each subsequent local delivery, which effectively changes the previous message, and may leave the new one in a non-conformant state.
1 parent e21c76a commit 239ff6d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

local.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ deliver_local(struct qitem *it)
130130
char fn[PATH_MAX+1];
131131
char line[1000];
132132
const char *sender;
133-
const char *newline = "\n";
134133
size_t linelen;
135134
int tries = 0;
136135
int mbox;
@@ -184,10 +183,6 @@ deliver_local(struct qitem *it)
184183

185184
mboxlen = lseek(mbox, 0, SEEK_END);
186185

187-
/* New mails start with \nFrom ...., unless we're at the beginning of the mbox */
188-
if (mboxlen == 0)
189-
newline = "";
190-
191186
/* If we're bouncing a message, claim it comes from MAILER-DAEMON */
192187
sender = it->sender;
193188
if (strcmp(sender, "") == 0)
@@ -198,7 +193,7 @@ deliver_local(struct qitem *it)
198193
goto out;
199194
}
200195

201-
error = snprintf(line, sizeof(line), "%sFrom %s %s", newline, sender, ctime(&now));
196+
error = snprintf(line, sizeof(line), "From %s %s", sender, ctime(&now));
202197
if (error < 0 || (size_t)error >= sizeof(line)) {
203198
syslog(LOG_NOTICE, "local delivery deferred: can not write header: %m");
204199
goto out;
@@ -241,6 +236,11 @@ deliver_local(struct qitem *it)
241236
if ((size_t)write(mbox, line, linelen) != linelen)
242237
goto wrerror;
243238
}
239+
240+
/* Each message in the mbox must be terminated by an empty line. */
241+
if (write(mbox, "\n", 1) != 1)
242+
goto wrerror;
243+
244244
close(mbox);
245245
return (0);
246246

0 commit comments

Comments
 (0)