From d6f90fc69e9dcec20441cc67bfc771c8588e5bbd Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 26 Jan 2022 16:09:29 +0200 Subject: [PATCH] auth: ldap: Drop partially saved results before retrying request Fixes "LDAP search returned multiple entries" happening after reconnects. --- src/auth/db-ldap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 80b3f4cc7b..8083108627 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -178,6 +178,7 @@ static bool db_ldap_abort_requests(struct ldap_connection *conn, unsigned int max_count, unsigned int timeout_secs, bool error, const char *reason); +static void db_ldap_request_free(struct ldap_request *request); static int deref2str(const char *str, int *ref_r) { @@ -410,6 +411,9 @@ static bool db_ldap_request_queue_next(struct ldap_connection *conn) whenever attempting to send the request. */ ret = 0; } else { + /* clear away any partial results saved before reconnecting */ + db_ldap_request_free(request); + switch (request->type) { case LDAP_REQUEST_TYPE_BIND: ret = db_ldap_request_bind(conn, request); @@ -893,7 +897,8 @@ db_ldap_request_free(struct ldap_request *request) if (named_res->result != NULL) db_ldap_result_unref(&named_res->result); } - array_clear(&srequest->named_results); + array_free(&srequest->named_results); + srequest->name_idx = 0; } } } -- 2.47.3