dovecot-2.2: ldap: Crashfix
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 26 10:36:55 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/aa8e77ab2b60
changeset: 16115:aa8e77ab2b60
user: Timo Sirainen <tss at iki.fi>
date: Tue Mar 26 10:36:49 2013 +0200
description:
ldap: Crashfix
diffstat:
src/auth/db-ldap.c | 45 ++++++++++++++++++---------------------------
src/auth/db-ldap.h | 3 ++-
src/auth/passdb-ldap.c | 9 +++++----
src/auth/userdb-ldap.c | 10 ++++++----
4 files changed, 31 insertions(+), 36 deletions(-)
diffs (215 lines):
diff -r 3396bc2575f5 -r aa8e77ab2b60 src/auth/db-ldap.c
--- a/src/auth/db-ldap.c Tue Mar 26 10:35:38 2013 +0200
+++ b/src/auth/db-ldap.c Tue Mar 26 10:36:49 2013 +0200
@@ -158,7 +158,7 @@
struct db_ldap_result_iterate_context *
db_ldap_result_iterate_init_full(struct ldap_connection *conn,
struct ldap_request_search *ldap_request,
- bool iter_dn_values);
+ LDAPMessage *res, bool iter_dn_values);
static int deref2str(const char *str)
{
@@ -547,14 +547,15 @@
}
static int db_ldap_fields_get_dn(struct ldap_connection *conn,
- struct ldap_request_search *request)
+ struct ldap_request_search *request,
+ LDAPMessage *res)
{
struct auth_request *auth_request = request->request.auth_request;
struct ldap_request_named_result *named_res;
struct db_ldap_result_iterate_context *ldap_iter;
const char *name, *const *values;
- ldap_iter = db_ldap_result_iterate_init_full(conn, request, TRUE);
+ ldap_iter = db_ldap_result_iterate_init_full(conn, request, res, TRUE);
while (db_ldap_result_iterate_next(ldap_iter, &name, &values)) {
if (values[1] != NULL) {
auth_request_log_warning(auth_request, "ldap",
@@ -668,7 +669,8 @@
}
static int db_ldap_search_next_subsearch(struct ldap_connection *conn,
- struct ldap_request_search *request)
+ struct ldap_request_search *request,
+ LDAPMessage *res)
{
struct ldap_request_named_result *named_res;
const struct ldap_field *field;
@@ -683,7 +685,7 @@
named_res = array_append_space(&request->named_results);
named_res->field = field;
}
- if (db_ldap_fields_get_dn(conn, request) < 0)
+ if (db_ldap_fields_get_dn(conn, request, res) < 0)
return -1;
} else {
request->name_idx++;
@@ -773,7 +775,7 @@
return FALSE;
}
} else {
- ret = db_ldap_search_next_subsearch(conn, srequest);
+ ret = db_ldap_search_next_subsearch(conn, srequest, res);
if (ret > 0) {
/* free this result, but not the others */
ldap_msgfree(res);
@@ -788,22 +790,12 @@
aqueue_delete(conn->request_queue, idx);
}
- if (srequest == NULL) {
- T_BEGIN {
- request->callback(conn, request, res);
- } T_END;
- } else {
- T_BEGIN {
- LDAPMessage *orig_result = srequest->result;
+ T_BEGIN {
+ if (res != NULL && srequest != NULL && srequest->result != NULL)
+ request->callback(conn, request, srequest->result);
- if (res != NULL && srequest->result != NULL)
- request->callback(conn, request, srequest->result);
-
- srequest->result = res;
- request->callback(conn, request, res);
- srequest->result = orig_result;
- } T_END;
- }
+ request->callback(conn, request, res);
+ } T_END;
if (idx > 0) {
/* see if there are timed out requests */
@@ -1453,15 +1445,13 @@
struct db_ldap_result_iterate_context *
db_ldap_result_iterate_init_full(struct ldap_connection *conn,
struct ldap_request_search *ldap_request,
- bool iter_dn_values)
+ LDAPMessage *res, bool iter_dn_values)
{
struct db_ldap_result_iterate_context *ctx;
const struct ldap_request_named_result *named_res;
const char *suffix;
pool_t pool;
- i_assert(ldap_request->result != NULL);
-
pool = pool_alloconly_create("ldap result iter", 1024);
ctx = p_new(pool, struct db_ldap_result_iterate_context, 1);
ctx->pool = pool;
@@ -1472,7 +1462,7 @@
if (ctx->auth_request->set->debug)
ctx->debug = t_str_new(256);
- get_ldap_fields(ctx, conn, ldap_request->result, "");
+ get_ldap_fields(ctx, conn, res, "");
if (array_is_created(&ldap_request->named_results)) {
array_foreach(&ldap_request->named_results, named_res) {
suffix = t_strdup_printf("@%s", named_res->field->name);
@@ -1485,9 +1475,10 @@
struct db_ldap_result_iterate_context *
db_ldap_result_iterate_init(struct ldap_connection *conn,
- struct ldap_request_search *ldap_request)
+ struct ldap_request_search *ldap_request,
+ LDAPMessage *res)
{
- return db_ldap_result_iterate_init_full(conn, ldap_request, FALSE);
+ return db_ldap_result_iterate_init_full(conn, ldap_request, res, FALSE);
}
static const char *db_ldap_field_get_default(const char *data)
diff -r 3396bc2575f5 -r aa8e77ab2b60 src/auth/db-ldap.h
--- a/src/auth/db-ldap.h Tue Mar 26 10:35:38 2013 +0200
+++ b/src/auth/db-ldap.h Tue Mar 26 10:36:49 2013 +0200
@@ -196,7 +196,8 @@
struct db_ldap_result_iterate_context *
db_ldap_result_iterate_init(struct ldap_connection *conn,
- struct ldap_request_search *ldap_request);
+ struct ldap_request_search *ldap_request,
+ LDAPMessage *res);
bool db_ldap_result_iterate_next(struct db_ldap_result_iterate_context *ctx,
const char **name_r,
const char *const **values_r);
diff -r 3396bc2575f5 -r aa8e77ab2b60 src/auth/passdb-ldap.c
--- a/src/auth/passdb-ldap.c Tue Mar 26 10:35:38 2013 +0200
+++ b/src/auth/passdb-ldap.c Tue Mar 26 10:36:49 2013 +0200
@@ -41,12 +41,13 @@
static void
ldap_query_save_result(struct ldap_connection *conn,
struct auth_request *auth_request,
- struct ldap_request_search *ldap_request)
+ struct ldap_request_search *ldap_request,
+ LDAPMessage *res)
{
struct db_ldap_result_iterate_context *ldap_iter;
const char *name, *const *values;
- ldap_iter = db_ldap_result_iterate_init(conn, ldap_request);
+ ldap_iter = db_ldap_result_iterate_init(conn, ldap_request, res);
while (db_ldap_result_iterate_next(ldap_iter, &name, &values)) {
if (values[1] != NULL) {
auth_request_log_warning(auth_request, "ldap",
@@ -129,7 +130,7 @@
if (ldap_request->entries++ == 0) {
/* first entry */
ldap_query_save_result(conn, auth_request,
- &ldap_request->request.search);
+ &ldap_request->request.search, res);
}
}
@@ -245,7 +246,7 @@
/* first entry */
ldap_query_save_result(conn, auth_request,
- &passdb_ldap_request->request.search);
+ &passdb_ldap_request->request.search, res);
/* save dn */
dn = ldap_get_dn(conn->ld, res);
diff -r 3396bc2575f5 -r aa8e77ab2b60 src/auth/userdb-ldap.c
--- a/src/auth/userdb-ldap.c Tue Mar 26 10:35:38 2013 +0200
+++ b/src/auth/userdb-ldap.c Tue Mar 26 10:36:49 2013 +0200
@@ -44,14 +44,15 @@
static void
ldap_query_get_result(struct ldap_connection *conn,
struct auth_request *auth_request,
- struct ldap_request_search *ldap_request)
+ struct ldap_request_search *ldap_request,
+ LDAPMessage *res)
{
struct db_ldap_result_iterate_context *ldap_iter;
const char *name, *const *values;
auth_request_init_userdb_reply(auth_request);
- ldap_iter = db_ldap_result_iterate_init(conn, ldap_request);
+ ldap_iter = db_ldap_result_iterate_init(conn, ldap_request, res);
while (db_ldap_result_iterate_next(ldap_iter, &name, &values)) {
auth_request_set_userdb_field_values(auth_request,
name, values);
@@ -100,7 +101,8 @@
if (urequest->entries++ == 0) {
/* first entry */
- ldap_query_get_result(conn, auth_request, &urequest->request);
+ ldap_query_get_result(conn, auth_request,
+ &urequest->request, res);
}
}
@@ -167,7 +169,7 @@
request->create_time = ioloop_time;
ctx->in_callback = TRUE;
- ldap_iter = db_ldap_result_iterate_init(conn, &urequest->request);
+ ldap_iter = db_ldap_result_iterate_init(conn, &urequest->request, res);
while (db_ldap_result_iterate_next(ldap_iter, &name, &values)) {
if (strcmp(name, "user") != 0) {
i_warning("ldap: iterate: "
More information about the dovecot-cvs
mailing list