summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2015-11-05 08:55:10 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2015-11-05 08:55:10 +0000
commit63ffad7f31e9f03cbe87f9ae9c92871ee7a4dc64 (patch)
treefa2d0d5c5b36c780e31a2fbe1908bce4c6ef5f99
parentad5845fd609dfa4c6b3bbdeeb522de5ae229f133 (diff)
when a message consists solely of headers and does not end them with an
empty line, the message parser gets confused, and forgets to flush last header to message file. detect if we're still in headers when hitting EOM, and flush if that is the case. reported by Philipp Takacs <philipp@bureaucracy.de> ok millert@, jung@, sunil@, eric@
-rw-r--r--usr.sbin/smtpd/rfc2822.c11
-rw-r--r--usr.sbin/smtpd/rfc2822.h3
-rw-r--r--usr.sbin/smtpd/smtp_session.c4
3 files changed, 15 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/rfc2822.c b/usr.sbin/smtpd/rfc2822.c
index 044a4686f60..14605d5aaa0 100644
--- a/usr.sbin/smtpd/rfc2822.c
+++ b/usr.sbin/smtpd/rfc2822.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfc2822.c,v 1.4 2015/09/07 15:36:53 gilles Exp $ */
+/* $OpenBSD: rfc2822.c,v 1.5 2015/11/05 08:55:09 gilles Exp $ */
/*
* Copyright (c) 2014 Gilles Chehade <gilles@poolp.org>
@@ -140,6 +140,15 @@ rfc2822_parser_init(struct rfc2822_parser *rp)
}
void
+rfc2822_parser_flush(struct rfc2822_parser *rp)
+{
+ if (! rp->in_hdrs)
+ return;
+
+ header_callback(rp);
+}
+
+void
rfc2822_parser_reset(struct rfc2822_parser *rp)
{
header_reset(&rp->header);
diff --git a/usr.sbin/smtpd/rfc2822.h b/usr.sbin/smtpd/rfc2822.h
index c78392d726a..48bdf6de495 100644
--- a/usr.sbin/smtpd/rfc2822.h
+++ b/usr.sbin/smtpd/rfc2822.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfc2822.h,v 1.3 2015/09/07 15:36:53 gilles Exp $ */
+/* $OpenBSD: rfc2822.h,v 1.4 2015/11/05 08:55:09 gilles Exp $ */
/*
* Copyright (c) 2014 Gilles Chehade <gilles@poolp.org>
@@ -68,6 +68,7 @@ struct rfc2822_parser {
void rfc2822_parser_init(struct rfc2822_parser *);
int rfc2822_parser_feed(struct rfc2822_parser *, const char *);
+void rfc2822_parser_flush(struct rfc2822_parser *);
void rfc2822_parser_reset(struct rfc2822_parser *);
void rfc2822_parser_release(struct rfc2822_parser *);
int rfc2822_header_callback(struct rfc2822_parser *, const char *,
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 6f745459c14..48278eb2995 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.238 2015/10/21 16:44:28 jsing Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.239 2015/11/05 08:55:09 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1104,6 +1104,8 @@ smtp_io(struct io *io, int evt)
/* End of body */
if (s->state == STATE_BODY) {
+ rfc2822_parser_flush(&s->rfc2822_parser);
+
iobuf_normalize(&s->iobuf);
io_set_write(io);