diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2014-03-25 10:06:30 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2014-03-25 10:06:30 +0000 |
commit | 74e6dddfe88b6313b12a7b565d5b98d935666ef4 (patch) | |
tree | 967f230a1dc8230c7d640846f1ab380ed73d9aaf /usr.sbin | |
parent | 15ab5937178e86d1ff6b575988ef7bffa5835dba (diff) |
when locally enqueuing messages without specifying a domain for sender or
recipient, the local domain is assumed. this was correctly handled at the
smtp level, but headers were not updated to reflect that.
issue experienced by several people, fix tested by ajacoutot@ and I
ok eric@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/enqueue.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index 60976ec8317..70d63c4c942 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.76 2014/03/13 14:28:33 chris Exp $ */ +/* $OpenBSD: enqueue.c,v 1.77 2014/03/25 10:06:29 gilles Exp $ */ /* * Copyright (c) 2005 Henning Brauer <henning@bulabula.org> @@ -159,6 +159,42 @@ qp_encoded_write(FILE *fp, char *buf, size_t len) } } +static void +send_header(FILE *fout, const char *line, size_t len) +{ + int i; + + if (strncasecmp("To:", line, 3) != 0 && + strncasecmp("Cc:", line, 3) != 0 && + strncasecmp("Bcc:", line, 4) != 0 && + strncasecmp("From:", line, 5) != 0) { + send_line(fout, 0, "%.*s", (int)len, line); + return; + } + if (len >= sizeof pstate.buf) { + send_line(fout, 0, "%.*s", (int)len, line); + return; + } + + /* XXX + * To, Cc and Bcc may need rewrite, we can reuse the + * msg recipients field since former content has already + * been used at this point. + */ + memset(&pstate, 0, sizeof(pstate)); + memcpy(pstate.buf, line, len); + pstate.buf[len] = 0; + pstate.wpos = len - 1; + msg.rcpts = NULL; + msg.rcpt_cnt = 0; + if (strncasecmp("From:", line, 5) == 0) + parse_addr_terminal(1); + else + parse_addr_terminal(0); + for (i = 0; i < msg.rcpt_cnt; ++i) + send_line(fout, 0, "%s%s\n", msg.rcpts[i], i < msg.rcpt_cnt - 1 ? "," : ""); +} + int enqueue(int argc, char *argv[]) { @@ -363,7 +399,10 @@ enqueue(int argc, char *argv[]) if (msg.saw_content_transfer_encoding || noheader || inheaders || !msg.need_linesplit) { - send_line(fout, 0, "%.*s", (int)len, line); + if (inheaders) + send_header(fout, line, len); + else + send_line(fout, 0, "%.*s", (int)len, line); if (inheaders && buf[0] == '\n') inheaders = 0; continue; |