diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2019-01-05 08:38:42 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2019-01-05 08:38:42 +0000 |
commit | 8e8c20995b7c4d70a4c81e088972da25bbb35c1c (patch) | |
tree | 4d041bb5717acadeaff75154851d1e8f215f2766 | |
parent | 73dcca385cbf64a3d815fafb4b254539d78b20cc (diff) |
move the DATA bytes accounting a bit earlier so that we don't have to deal
with it using special cases for when filters are enabled or not.
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index e2a21de186b..8b1de9e5dfc 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.385 2019/01/03 15:46:07 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.386 2019/01/05 08:38:41 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1083,6 +1083,11 @@ smtp_io(struct io *io, int evt, void *arg) /* Message body */ eom = 0; if (s->state == STATE_BODY) { + if (strcmp(line, ".")) { + s->tx->datain += strlen(line) + 1; + if (s->tx->datain > env->sc_maxsize) + s->tx->error = TX_ERROR_SIZE; + } eom = (s->tx->filter == NULL) ? smtp_tx_dataline(s->tx, line) : smtp_tx_filtered_dataline(s->tx, line); @@ -2553,13 +2558,6 @@ smtp_tx_dataline(struct smtp_tx *tx, const char *line) /* escape lines starting with a '.' */ if (line[0] == '.') line += 1; - - /* account for newline */ - tx->datain += strlen(line) + 1; - if (tx->datain > env->sc_maxsize) { - tx->error = TX_ERROR_SIZE; - return 0; - } } if (rfc5322_push(tx->parser, line) == -1) { @@ -2666,25 +2664,12 @@ smtp_tx_dataline(struct smtp_tx *tx, const char *line) static int smtp_tx_filtered_dataline(struct smtp_tx *tx, const char *line) { - if (!strcmp(line, ".")) { - /* XXX - this needs to be handled properly */ - /* - * if (tx->error) - * return 1; - */ + if (!strcmp(line, ".")) line = NULL; - } else { /* ignore data line if an error is set */ if (tx->error) return 0; - - /* account for newline */ - tx->datain += strlen(line) + 1; - if (tx->datain > env->sc_maxsize) { - tx->error = TX_ERROR_SIZE; - return 0; - } } io_printf(tx->filter, "%s\r\n", line ? line : "."); return line ? 0 : 1; |