dovecot-2.0: auth: Fixed blocking userdb lookups.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 16 18:08:30 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/bf26a6ec3389
changeset: 10923:bf26a6ec3389
user: Timo Sirainen <tss at iki.fi>
date: Tue Mar 16 18:08:27 2010 +0200
description:
auth: Fixed blocking userdb lookups.
diffstat:
src/auth/auth-worker-client.c | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diffs (73 lines):
diff -r 55e3817f09da -r bf26a6ec3389 src/auth/auth-worker-client.c
--- a/src/auth/auth-worker-client.c Tue Mar 16 18:02:53 2010 +0200
+++ b/src/auth/auth-worker-client.c Tue Mar 16 18:08:27 2010 +0200
@@ -379,15 +379,27 @@
auth_worker_client_unref(&client);
}
+static struct auth_userdb *
+auth_userdb_find_by_id(struct auth_userdb *userdbs, unsigned int id)
+{
+ struct auth_userdb *db;
+
+ for (db = userdbs; db != NULL; db = db->next) {
+ if (db->userdb->id == id)
+ return db;
+ }
+ return NULL;
+}
+
static bool
auth_worker_handle_user(struct auth_worker_client *client,
unsigned int id, const char *args)
{
/* lookup user */
struct auth_request *auth_request;
- unsigned int num;
+ unsigned int userdb_id;
- num = atoi(t_strcut(args, '\t'));
+ userdb_id = atoi(t_strcut(args, '\t'));
args = strchr(args, '\t');
if (args != NULL) args++;
@@ -399,13 +411,12 @@
return FALSE;
}
- for (; num > 0; num--) {
- auth_request->userdb = auth_request->userdb->next;
- if (auth_request->userdb == NULL) {
- i_error("BUG: USER had invalid userdb num");
- auth_request_unref(&auth_request);
- return FALSE;
- }
+ auth_request->userdb =
+ auth_userdb_find_by_id(auth_request->userdb, userdb_id);
+ if (auth_request->userdb == NULL) {
+ i_error("BUG: USER had invalid userdb ID");
+ auth_request_unref(&auth_request);
+ return FALSE;
}
auth_request->userdb->userdb->iface->
@@ -488,15 +499,11 @@
{
struct auth_worker_list_context *ctx;
struct auth_userdb *userdb;
- unsigned int num;
- userdb = client->auth->userdbs;
- for (num = atoi(args); num > 0; num--) {
- userdb = userdb->next;
- if (userdb == NULL) {
- i_error("BUG: LIST had invalid userdb num");
- return FALSE;
- }
+ userdb = auth_userdb_find_by_id(client->auth->userdbs, atoi(args));
+ if (userdb == NULL) {
+ i_error("BUG: LIST had invalid userdb ID");
+ return FALSE;
}
ctx = i_new(struct auth_worker_list_context, 1);
More information about the dovecot-cvs
mailing list