From b8e0e6c287dc269a734f517dd56dfc224b732790 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 19 Nov 2009 12:51:20 +0100 Subject: [PATCH] Login handlers: Check status code of replies. --- src/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.c b/src/main.c index 4ad7e8f..1c9fefe 100644 --- a/src/main.c +++ b/src/main.c @@ -638,6 +638,12 @@ static int login2_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ printf ("login2_handler has been called.\n"); reply_dump (r); + if (strcmp (r->status, "done") != 0) + { + mt_debug ("login2_handler: Unexpected status: %s.\n", r->status); + return (EPROTO); + } + return (0); } /* }}} int login2_handler */ @@ -709,9 +715,22 @@ static int login_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ if (r == NULL) return (EINVAL); + /* The expected result looks like this: + * -- 8< -- + * !done + * =ret=ebddd18303a54111e2dea05a92ab46b4 + * -- >8 -- + */ + printf ("login_handler has been called.\n"); reply_dump (r); + if (strcmp (r->status, "done") != 0) + { + mt_debug ("login_handler: Unexpected status: %s.\n", r->status); + return (EPROTO); + } + login_data = user_data; if (login_data == NULL) return (EINVAL); -- 2.11.0