From: epg <> Date: Sun, 25 Aug 2002 06:50:37 +0000 (+0000) Subject: (deliver): Check for and strip 'From ' line that some broken mailers X-Git-Url: https://diplodocus.org/git/mdeliver/commitdiff_plain/76e6c4793248607e2e6bf06adbae839b13bf5da2 (deliver): Check for and strip 'From ' line that some broken mailers (such as Postfix) add as the first line of input. --- diff --git a/mdeliver.c b/mdeliver.c index 99eaec1..03f5c99 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -119,6 +119,33 @@ deliver(char *maildir, char *newfn) /* From this point, we have a tmp file, so if someting fails we * must try to unlink it before bombing. */ + { + r = read(STDIN_FILENO, buf, 5); + if (r != 5) { + unlink(fn); + err(EX_TEMPFAIL, "Failed read from stdin"); + } + + if (strncmp(buf, "From ", 5)) { + while ((r = read(STDIN_FILENO, buf, 1)) > 0 + || (r == -1 && errno == EINTR)) { + if (buf[0] == '\n') { + break; + } + } + + if (r == -1) { + unlink(fn); + err(EX_TEMPFAIL, "Failed read from stdin"); + } + } else { + if (full_write(fd, buf, r) != r) { + unlink(fn); + err(EX_TEMPFAIL, "Failed write(%s)", fn); + } + } + } + while ((r = read(STDIN_FILENO, buf, BUFSIZ)) > 0 || (r == -1 && errno == EINTR)) { if (full_write(fd, buf, r) != r) {