aboutsummaryrefslogtreecommitdiffstats
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
commit707c272e0cf1525b10d80ac471d72c2a3bf6740f (patch)
tree1078305b8fbb01617ef1c0c0c10190da51911e78
parent ce examples of "Ar arg Ar arg" with "Ar arg arg" and stop the spread; (diff)
downloadOpenSMTPD-707c272e0cf1525b10d80ac471d72c2a3bf6740f.tar.xz
OpenSMTPD-707c272e0cf1525b10d80ac471d72c2a3bf6740f.zip
strip trailing CRs at smtp level rather than io level
ok millert@
-rw-r--r--bounce.c6
-rw-r--r--iobuf.c7
-rw-r--r--lka_filter.c4
-rw-r--r--mta_session.c6
-rw-r--r--smtp_client.c6
-rw-r--r--smtp_session.c6
6 files changed, 25 insertions, 10 deletions
diff --git a/bounce.c b/bounce.c
index 4ce0ff71..e6fc5578 100644
--- a/bounce.c
+++ b/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/iobuf.c b/iobuf.c
index f5d8b20a..e8a178ab 100644
--- a/iobuf.c
+++ b/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/lka_filter.c b/lka_filter.c
index 715ab831..bcb76f89 100644
--- a/lka_filter.c
+++ b/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/mta_session.c b/mta_session.c
index 8710d379..fa7c7e1c 100644
--- a/mta_session.c
+++ b/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/smtp_client.c b/smtp_client.c
index 528f48b7..8e146e1b 100644
--- a/smtp_client.c
+++ b/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/smtp_session.c b/smtp_session.c
index d6c45b92..5ea9f89e 100644
--- a/smtp_session.c
+++ b/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) {