summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-05-24 14:58:44 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-05-24 14:58:44 +0000
commitd708060fbfe712c8917ffffd5eabcbb3f8fa100e (patch)
tree01d407c46deed4295c64865298a4a6116d6be489
parent72f320d789e26f1a6d777dd158641de3038990ac (diff)
Implement pipelining detection inside session_readline, makes the calling
code cleaner; ok gilles@
-rw-r--r--usr.sbin/smtpd/smtp_session.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 7c098468c0d..d06d2b17da8 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.94 2009/05/24 14:22:24 jacekm Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.95 2009/05/24 14:58:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -732,24 +732,12 @@ session_read(struct bufferevent *bev, void *p)
struct session *s = p;
char *line;
size_t nr;
- int expect_lines = 1;
for (;;) {
line = session_readline(s, &nr);
if (line == NULL)
return;
- if (! expect_lines) {
- session_respond(s, "500 Pipelining unsupported");
- s->s_env->stats->smtp.toofast++;
- s->s_flags |= F_QUIT;
- return;
- }
- expect_lines = 0;
-
- if (s->s_flags & F_WRITEONLY)
- fatalx("session_read: corrupt session");
-
switch (s->s_state) {
case S_AUTH_INIT:
case S_AUTH_USERNAME:
@@ -774,8 +762,6 @@ session_read(struct bufferevent *bev, void *p)
break;
case S_DATACONTENT:
- if (strcmp(line, ".") != 0)
- expect_lines = 1;
session_read_data(s, line, nr);
break;
@@ -981,7 +967,7 @@ session_destroy(struct session *s)
char *
session_readline(struct session *s, size_t *nr)
{
- char *line;
+ char *line, *line2;
*nr = EVBUFFER_LENGTH(s->s_bev->input);
line = evbuffer_readline(s->s_bev->input);
@@ -995,6 +981,20 @@ session_readline(struct session *s, size_t *nr)
}
*nr -= EVBUFFER_LENGTH(s->s_bev->input);
+ if (s->s_flags & F_WRITEONLY)
+ fatalx("session_readline: corrupt session");
+
+ if ((s->s_state != S_DATACONTENT || strcmp(line, ".") == 0) &&
+ (line2 = evbuffer_readline(s->s_bev->input)) != NULL) {
+ session_respond(s, "500 Pipelining unsupported");
+ s->s_env->stats->smtp.toofast++;
+ s->s_flags |= F_QUIT;
+ free(line);
+ free(line2);
+
+ return NULL;
+ }
+
return line;
}