[dovecot-cvs] dovecot/src/login-common sasl-server.c, 1.10.2.6, 1.10.2.7
tss at dovecot.org
tss at dovecot.org
Wed Mar 7 01:59:42 EET 2007
Update of /var/lib/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv10397
Modified Files:
Tag: branch_1_0
sasl-server.c
Log Message:
After calling sasl_callback() the client may be destroyed already. Don't try
to modify it.
Index: sasl-server.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/sasl-server.c,v
retrieving revision 1.10.2.6
retrieving revision 1.10.2.7
diff -u -d -r1.10.2.6 -r1.10.2.7
--- sasl-server.c 16 Feb 2007 13:40:46 -0000 1.10.2.6
+++ sasl-server.c 6 Mar 2007 23:59:40 -0000 1.10.2.7
@@ -22,12 +22,26 @@
return auth_flags;
}
+static void
+call_client_callback(struct client *client, enum sasl_server_reply reply,
+ const char *data, const char *const *args)
+{
+ sasl_server_callback_t *sasl_callback;
+
+ i_assert(reply != SASL_SERVER_REPLY_CONTINUE);
+
+ sasl_callback = client->sasl_callback;
+ client->sasl_callback = NULL;
+
+ sasl_callback(client, reply, data, args);
+ /* NOTE: client may be destroyed now */
+}
+
static void master_callback(struct client *client, bool success)
{
client->authenticating = FALSE;
- client->sasl_callback(client, success ? SASL_SERVER_REPLY_SUCCESS :
- SASL_SERVER_REPLY_MASTER_FAILED, NULL, NULL);
- client->sasl_callback = NULL;
+ call_client_callback(client, success ? SASL_SERVER_REPLY_SUCCESS :
+ SASL_SERVER_REPLY_MASTER_FAILED, NULL, NULL);
}
static void authenticate_callback(struct auth_request *request, int status,
@@ -70,9 +84,8 @@
if (nologin) {
client->authenticating = FALSE;
- client->sasl_callback(client, SASL_SERVER_REPLY_SUCCESS,
- NULL, args);
- client->sasl_callback = NULL;
+ call_client_callback(client, SASL_SERVER_REPLY_SUCCESS,
+ NULL, args);
} else {
master_request_login(client, master_callback,
auth_client_request_get_server_pid(request),
@@ -94,9 +107,8 @@
}
client->authenticating = FALSE;
- client->sasl_callback(client, SASL_SERVER_REPLY_AUTH_FAILED,
- NULL, args);
- client->sasl_callback = NULL;
+ call_client_callback(client, SASL_SERVER_REPLY_AUTH_FAILED,
+ NULL, args);
break;
}
}
@@ -168,8 +180,7 @@
client->auth_request = NULL;
}
- client->sasl_callback(client, reply, reason, NULL);
- client->sasl_callback = NULL;
+ call_client_callback(client, reply, reason, NULL);
}
void sasl_server_auth_failed(struct client *client, const char *reason)
More information about the dovecot-cvs
mailing list