summaryrefslogtreecommitdiffstats
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2020-04-24 11:34:07 +0000
committereric <eric@openbsd.org>2020-04-24 11:34:07 +0000
commit0124f38d023630a3318773ee07a22cd171c56225 (patch)
tree301660d366fa164ff29c8c98499db41d1a58524d /usr.sbin/smtpd
parentMake sure devices are properly closed in case of an error. (diff)
downloadwireguard-openbsd-0124f38d023630a3318773ee07a22cd171c56225.tar.xz
wireguard-openbsd-0124f38d023630a3318773ee07a22cd171c56225.zip
strip trailing CRs at smtp level rather than io level
ok millert@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/bounce.c6
-rw-r--r--usr.sbin/smtpd/iobuf.c7
-rw-r--r--usr.sbin/smtpd/lka_filter.c4
-rw-r--r--usr.sbin/smtpd/mta_session.c6
-rw-r--r--usr.sbin/smtpd/smtp_client.c6
-rw-r--r--usr.sbin/smtpd/smtp_session.c6
6 files changed, 25 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index 4ce0ff713fc..e6fc55780a1 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.81 2019/11/25 12:11:26 eric Exp $ */
+/* $OpenBSD: bounce.c,v 1.82 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@poolp.org>
@@ -728,6 +728,10 @@ bounce_io(struct io *io, int evt, void *arg)
if (line == NULL)
break;
+ /* Strip trailing '\r' */
+ if (len && line[len - 1] == '\r')
+ line[--len] = '\0';
+
log_trace(TRACE_BOUNCE, "bounce: %p: <<< %s", s, line);
if ((error = parse_smtp_response(line, len, &msg, &cont))) {
diff --git a/usr.sbin/smtpd/iobuf.c b/usr.sbin/smtpd/iobuf.c
index f5d8b20aeef..e8a178abe24 100644
--- a/usr.sbin/smtpd/iobuf.c
+++ b/usr.sbin/smtpd/iobuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iobuf.c,v 1.12 2019/10/03 07:03:23 gilles Exp $ */
+/* $OpenBSD: iobuf.c,v 1.13 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -174,10 +174,9 @@ iobuf_getline(struct iobuf *iobuf, size_t *rlen)
* the next call to iobuf_normalize() or iobuf_extend().
*/
iobuf_drop(iobuf, i + 1);
- len = (i && buf[i - 1] == '\r') ? i - 1 : i;
- buf[len] = '\0';
+ buf[i] = '\0';
if (rlen)
- *rlen = len;
+ *rlen = i;
return (buf);
}
diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c
index 715ab831db7..bcb76f897e6 100644
--- a/usr.sbin/smtpd/lka_filter.c
+++ b/usr.sbin/smtpd/lka_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_filter.c,v 1.61 2020/04/17 14:20:13 eric Exp $ */
+/* $OpenBSD: lka_filter.c,v 1.62 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -851,7 +851,7 @@ filter_data_internal(struct filter_session *fs, uint64_t token, uint64_t reqid,
/* no filter_entry, we either had none or reached end of chain */
if (filter_entry == NULL) {
- io_printf(fs->io, "%s\r\n", line);
+ io_printf(fs->io, "%s\n", line);
return;
}
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index 8710d379f6e..fa7c7e1ce0d 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.134 2020/04/10 19:28:57 beck Exp $ */
+/* $OpenBSD: mta_session.c,v 1.135 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -1257,6 +1257,10 @@ mta_io(struct io *io, int evt, void *arg)
return;
}
+ /* Strip trailing '\r' */
+ if (len && line[len - 1] == '\r')
+ line[--len] = '\0';
+
log_trace(TRACE_MTA, "mta: %p: <<< %s", s, line);
mta_report_protocol_server(s, line);
diff --git a/usr.sbin/smtpd/smtp_client.c b/usr.sbin/smtpd/smtp_client.c
index 528f48b7f07..8e146e1b7c2 100644
--- a/usr.sbin/smtpd/smtp_client.c
+++ b/usr.sbin/smtpd/smtp_client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_client.c,v 1.13 2020/02/24 23:54:27 millert Exp $ */
+/* $OpenBSD: smtp_client.c,v 1.14 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2018 Eric Faurot <eric@openbsd.org>
@@ -680,6 +680,10 @@ smtp_client_readline(struct smtp_client *proto)
return 0;
}
+ /* Strip trailing '\r' */
+ if (len && line[len - 1] == '\r')
+ line[--len] = '\0';
+
log_trace(TRACE_SMTPCLT, "%p: <<< %s", proto, line);
/* Validate SMTP */
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index d6c45b92797..5ea9f89ed9a 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.425 2020/03/15 16:34:57 millert Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.426 2020/04/24 11:34:07 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1132,6 +1132,10 @@ smtp_io(struct io *io, int evt, void *arg)
if (line == NULL)
return;
+ /* Strip trailing '\r' */
+ if (len && line[len - 1] == '\r')
+ line[--len] = '\0';
+
/* Message body */
eom = 0;
if (s->state == STATE_BODY) {