From dbe3b1b7742af72b8c3c9e48b854843e37b79933 Mon Sep 17 00:00:00 2001 From: chris mikkelson Date: Tue, 24 Mar 2009 23:53:47 -0500 Subject: [PATCH] Fixed DATA state machine, and quit response. --- smtp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/smtp.c b/smtp.c index 5035464..7b16300 100644 --- a/smtp.c +++ b/smtp.c @@ -106,6 +106,7 @@ smtpd_data(struct conn *c, char *cmd, int len, int argoff) if (c->state != SMTP_RCPT) return respond(c, err_wantrcpt); c->state = SMTP_DATA; + c->dstate = 2; return respond(c, data_ok); } @@ -147,7 +148,7 @@ static int smtpd_quit(struct conn *c, char *cmd, int len, int argoff) { c->state = SMTP_CLOSED; - return respond(c, quit_ok); + return respond(c, quit_ok, banner_hostname); } static int @@ -194,6 +195,8 @@ do_command(struct conn *c, char *cmd, int len) static int do_smtp(struct conn *c, char **buf, int *len) { + if (*len == 0) return 0; + if (c->state == SMTP_DATA) { char *s; for (s = *buf; s < *buf + *len; s++) { @@ -212,10 +215,11 @@ do_smtp(struct conn *c, char **buf, int *len) continue; case 4: if (*s == '\n') { c->dstate = 5; - break; + continue; } c->dstate = 0; continue; + case 5: break; } break; } -- 2.50.1