summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2019-01-05 08:38:41 +0000
committergilles <gilles@openbsd.org>2019-01-05 08:38:41 +0000
commit3cf208264e8c75918113cfd3f390bb94cd185c7e (patch)
tree03b3b3021144a8fbd220fa429c7cf41f757e0fff
parentmatch arm64 and print unconfigured simplebus devices on armv7 (diff)
downloadwireguard-openbsd-3cf208264e8c75918113cfd3f390bb94cd185c7e.tar.xz
wireguard-openbsd-3cf208264e8c75918113cfd3f390bb94cd185c7e.zip
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.c29
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;