tttm

git clone https://orangeshoelaces.net/git/tttm.git

97fddfa73a18b2d36fc406329a4646f741999b4a

Author: Vasily Kolobkov on 06/03/2016

Committer: Vasily Kolobkov on 06/03/2016

React properly to BYE greetings

Stats

imap.c | 6 ++++++
1 file changed, 6 insertions(+)

Patch

diff --git a/imap.c b/imap.c
index 1929d92..85794b8 100644
--- a/imap.c
+++ b/imap.c
@@ -383,6 +383,9 @@ imap_recvgreets(struct imapctx *con)
 		con->state = IS_AUTH;
 	} else if ((n = par_sel(con->par, IP_RESPDATA, IP_RESPSTATE, -1))) {
 		con->state = IS_NAUTH;
+	} else if ((n = par_sel(con->par, IP_RESPDATA, IP_RESPBYE, -1))) {
+		con->state = IS_LOGOUT;
+		goto ebye;
 	} else {
 		goto eproto;
 	}
@@ -391,6 +394,9 @@ imap_recvgreets(struct imapctx *con)
 		e = imap_parcaps(con, n);
  exit:
 	return e;
+ ebye:
+	e = TE_BYE;
+	goto exit;
  eproto:
 	e = TE_PROTO;
 	goto exit;