summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2018-02-16 20:57:31 +0000
committerEric Faurot <eric@cvs.openbsd.org>2018-02-16 20:57:31 +0000
commit0a971798851a4e3c6276f83edfb117c46f634be1 (patch)
treec09db853eb2f56d377026b79a30b55a39316bf19 /usr.sbin/smtpd
parente03a65857290c29b314308d20d9306b05dd5bfae (diff)
bump max line length to 16K for incoming mail.
SMTP commands are still limited to LINE_MAX. ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/rfc2822.h4
-rw-r--r--usr.sbin/smtpd/smtp_session.c18
2 files changed, 15 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/rfc2822.h b/usr.sbin/smtpd/rfc2822.h
index 48bdf6de495..2132cca61cc 100644
--- a/usr.sbin/smtpd/rfc2822.h
+++ b/usr.sbin/smtpd/rfc2822.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rfc2822.h,v 1.4 2015/11/05 08:55:09 gilles Exp $ */
+/* $OpenBSD: rfc2822.h,v 1.5 2018/02/16 20:57:30 eric Exp $ */
/*
* Copyright (c) 2014 Gilles Chehade <gilles@poolp.org>
@@ -19,7 +19,7 @@
#ifndef _RFC2822_H_
#define _RFC2822_H_
-#define RFC2822_MAX_LINE_SIZE 4096
+#define RFC2822_MAX_LINE_SIZE 16384
struct rfc2822_line {
TAILQ_ENTRY(rfc2822_line) next;
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 61ed2cac853..ad64f94e4a8 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.316 2018/02/09 09:29:03 eric Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.317 2018/02/16 20:57:30 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -45,8 +45,9 @@
#include "log.h"
#include "ssl.h"
+#define SMTP_LINE_MAX 16384
#define DATA_HIWAT 65535
-#define APPEND_DOMAIN_BUFFER_SIZE 4096
+#define APPEND_DOMAIN_BUFFER_SIZE SMTP_LINE_MAX
enum smtp_state {
STATE_NEW = 0,
@@ -1007,8 +1008,8 @@ smtp_io(struct io *io, int evt, void *arg)
case IO_DATAIN:
nextline:
line = io_getline(s->io, &len);
- if ((line == NULL && io_datalen(s->io) >= LINE_MAX) ||
- (line && len >= LINE_MAX)) {
+ if ((line == NULL && io_datalen(s->io) >= SMTP_LINE_MAX) ||
+ (line && len >= SMTP_LINE_MAX)) {
s->flags |= SF_BADINPUT;
smtp_reply(s, "500 %s: Line too long",
esc_code(ESC_STATUS_PERMFAIL, ESC_OTHER_STATUS));
@@ -1047,7 +1048,14 @@ smtp_io(struct io *io, int evt, void *arg)
}
/* Must be a command */
- (void)strlcpy(s->cmd, line, sizeof s->cmd);
+ if (strlcpy(s->cmd, line, sizeof(s->cmd)) >= sizeof(s->cmd)) {
+ s->flags |= SF_BADINPUT;
+ smtp_reply(s, "500 %s: Command line too long",
+ esc_code(ESC_STATUS_PERMFAIL, ESC_OTHER_STATUS));
+ smtp_enter_state(s, STATE_QUIT);
+ io_set_write(io);
+ return;
+ }
io_set_write(io);
smtp_command(s, line);
break;