Mercurial > dovecot > core-2.2
changeset 4770:88c29111fcee HEAD
Crashfixes and more asserts. Mostly related to use of AUTHENTICATE/AUTH
commands.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 07 Nov 2006 17:06:23 +0200 |
parents | e67acfeb2fd5 |
children | 7576055e5377 |
files | src/imap-login/client-authenticate.c src/imap-login/client.c src/imap-login/imap-proxy.c src/login-common/client-common.h src/login-common/sasl-server.c src/pop3-login/client-authenticate.c src/pop3-login/client.c src/pop3-login/pop3-proxy.c |
diffstat | 8 files changed, 36 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-login/client-authenticate.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/imap-login/client-authenticate.c Tue Nov 07 17:06:23 2006 +0200 @@ -68,12 +68,12 @@ return; } - if (client->common.auth_request == NULL) { + if (client->common.waiting_auth_reply) { sasl_server_auth_client_error(&client->common, "Don't send unrequested data"); } else { auth_client_request_continue(client->common.auth_request, line); - client->common.auth_request = NULL; + client->common.waiting_auth_reply = TRUE; } /* clear sensitive data */ @@ -182,6 +182,8 @@ const char *msg; size_t data_len; + i_assert(!client->destroyed || reply == SASL_SERVER_REPLY_CLIENT_ERROR); + switch (reply) { case SASL_SERVER_REPLY_SUCCESS: if (args != NULL) {
--- a/src/imap-login/client.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/imap-login/client.c Tue Nov 07 17:06:23 2006 +0200 @@ -469,8 +469,10 @@ o_stream_close(client->output); if (client->common.auth_request != NULL) { - auth_client_request_abort(client->common.auth_request); - client->common.auth_request = NULL; + i_assert(client->common.authenticating); + sasl_server_auth_client_error(&client->common, NULL); + } else { + i_assert(!client->common.authenticating); } if (client->common.master_tag != 0)
--- a/src/imap-login/imap-proxy.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/imap-login/imap-proxy.c Tue Nov 07 17:06:23 2006 +0200 @@ -15,14 +15,7 @@ { string_t *str; - if (client->destroyed) { - /* client already disconnected. */ - login_proxy_free(client->proxy); - client->proxy = NULL; - - client_unref(client); - return -1; - } + i_assert(!client->destroyed); if (!client->proxy_login_sent) { /* this is a banner */ @@ -132,6 +125,7 @@ unsigned int port, const char *user, const char *password) { i_assert(user != NULL); + i_assert(!client->destroyed); if (password == NULL) { i_error("proxy(%s): password not given", @@ -142,6 +136,12 @@ i_assert(client->refcount > 1); connection_queue_add(1); + if (client->destroyed) { + /* connection_queue_add() decided that we were the oldest + connection and killed us. */ + return -1; + } + client_ref(client); client->proxy = login_proxy_new(&client->common, host, port, proxy_input, client);
--- a/src/login-common/client-common.h Tue Nov 07 16:55:32 2006 +0200 +++ b/src/login-common/client-common.h Tue Nov 07 17:06:23 2006 +0200 @@ -23,6 +23,7 @@ unsigned int tls:1; unsigned int secured:1; unsigned int authenticating:1; + unsigned int waiting_auth_reply:1; /* ... */ };
--- a/src/login-common/sasl-server.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/login-common/sasl-server.c Tue Nov 07 17:06:23 2006 +0200 @@ -37,6 +37,7 @@ unsigned int i; bool nologin; + i_assert(client->auth_request == request); if (!client->authenticating) { /* client aborted */ i_assert(status < 0); @@ -46,14 +47,7 @@ switch (status) { case 0: /* continue */ - if (client->auth_request != NULL) { - i_assert(client->auth_request == request); - } else { - i_assert(client->auth_request == NULL); - - client->auth_request = request; - } - + client->waiting_auth_reply = FALSE; client->sasl_callback(client, SASL_SERVER_REPLY_CONTINUE, data_base64, NULL); break;
--- a/src/pop3-login/client-authenticate.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/pop3-login/client-authenticate.c Tue Nov 07 17:06:23 2006 +0200 @@ -75,12 +75,12 @@ return; } - if (client->common.auth_request == NULL) { + if (client->common.waiting_auth_reply) { sasl_server_auth_client_error(&client->common, "Don't send unrequested data"); } else { auth_client_request_continue(client->common.auth_request, line); - client->common.auth_request = NULL; + client->common.waiting_auth_reply = TRUE; } /* clear sensitive data */ @@ -156,6 +156,8 @@ const char *msg; size_t data_len; + i_assert(!client->destroyed || reply == SASL_SERVER_REPLY_CLIENT_ERROR); + switch (reply) { case SASL_SERVER_REPLY_SUCCESS: if (args != NULL) {
--- a/src/pop3-login/client.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/pop3-login/client.c Tue Nov 07 17:06:23 2006 +0200 @@ -360,8 +360,10 @@ o_stream_close(client->output); if (client->common.auth_request != NULL) { - auth_client_request_abort(client->common.auth_request); - client->common.auth_request = NULL; + i_assert(client->common.authenticating); + sasl_server_auth_client_error(&client->common, NULL); + } else { + i_assert(!client->common.authenticating); } if (client->common.master_tag != 0)
--- a/src/pop3-login/pop3-proxy.c Tue Nov 07 16:55:32 2006 +0200 +++ b/src/pop3-login/pop3-proxy.c Tue Nov 07 17:06:23 2006 +0200 @@ -17,6 +17,8 @@ string_t *str; const char *line; + i_assert(!client->destroyed); + if (input == NULL) { if (client->io != NULL) { /* remote authentication failed, we're just @@ -138,6 +140,7 @@ unsigned int port, const char *user, const char *password) { i_assert(user != NULL); + i_assert(!client->destroyed); if (password == NULL) { i_error("proxy(%s): password not given", @@ -148,6 +151,12 @@ i_assert(client->refcount > 1); connection_queue_add(1); + if (client->destroyed) { + /* connection_queue_add() decided that we were the oldest + connection and killed us. */ + return -1; + } + client_ref(client); client->proxy = login_proxy_new(&client->common, host, port, proxy_input, client);