summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2008-11-17 21:50:44 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2008-11-17 21:50:44 +0000
commit733d56667b225a575f8de3c93dce2ec946da0896 (patch)
tree37193eaa7dc848b501ac9112c8460c10c1057a0e
parentff27942b5003c934d6b5d4eeade7741606acaa20 (diff)
- until now a client could issue a command from an extension even though it
greeted with helo and not ehlo. introduce session flag F_EHLO and make sure the session_command() dispatch only looks at extensions when a session does not have the F_EHLO flag.
-rw-r--r--usr.sbin/smtpd/smtp_session.c7
-rw-r--r--usr.sbin/smtpd/smtpd.h13
2 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 3f32e2905cd..9a268d1c5db 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.6 2008/11/17 20:11:27 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.7 2008/11/17 21:50:43 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -275,6 +275,7 @@ session_rfc5321_ehlo_handler(struct session *s, char *args)
}
s->s_state = S_HELO;
+ s->s_flags |= F_EHLO;
s->s_flags |= F_8BITMIME;
if (s->s_ss.ss_family == PF_INET) {
@@ -495,6 +496,9 @@ session_command(struct session *s, char *cmd, char *args)
{
int i;
+ if (!(s->s_flags & F_EHLO))
+ goto rfc5321;
+
/* RFC 1652 - 8BITMIME */
for (i = 0; i < (int)(sizeof(rfc1652_cmdtab) / sizeof(struct session_cmd)); ++i)
if (strcasecmp(rfc1652_cmdtab[i].name, cmd) == 0)
@@ -524,6 +528,7 @@ session_command(struct session *s, char *cmd, char *args)
}
*/
+rfc5321:
/* RFC 5321 - SMTP */
for (i = 0; i < (int)(sizeof(rfc5321_cmdtab) / sizeof(struct session_cmd)); ++i)
if (strcasecmp(rfc5321_cmdtab[i].name, cmd) == 0)
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 635c7e651f5..7cfc6e32748 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.10 2008/11/17 21:27:50 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.11 2008/11/17 21:50:43 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -563,11 +563,12 @@ struct session_auth_reply {
};
enum session_flags {
- F_QUIT = 0x1,
- F_IMSG_SENT = 0x2,
- F_8BITMIME = 0x4,
- F_SECURE = 0x8,
- F_AUTHENTICATED = 0x10
+ F_EHLO = 0x1,
+ F_QUIT = 0x2,
+ F_IMSG_SENT = 0x4,
+ F_8BITMIME = 0x8,
+ F_SECURE = 0x10,
+ F_AUTHENTICATED = 0x20
};
struct session {