Hi In my last patch I have missed that ldap_query() returns 0 even when aldap doesn't return a message. A fix is attached.
Philipp
From d9fbbd077cd72cf75105193d75d9d3779b865f42 Mon Sep 17 00:00:00 2001 From: Philipp Takacs <phil...@bureaucracy.de> Date: Mon, 29 Jan 2024 15:53:12 +0100 Subject: [PATCH] table-ldap ldap_query() return -1 when the ldap server don't response --- extras/tables/table-ldap/table_ldap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extras/tables/table-ldap/table_ldap.c b/extras/tables/table-ldap/table_ldap.c index 29cc15a..772a1a5 100644 --- a/extras/tables/table-ldap/table_ldap.c +++ b/extras/tables/table-ldap/table_ldap.c @@ -413,7 +413,7 @@ ldap_query(const char *filter, const char *key, char **attributes, char ***outp, return -1; if (strlcpy(key__, key, sizeof key__) >= sizeof key__) return -1; - found = 0; + found = -1; do { if ((ret = aldap_search(aldap, basedn__, LDAP_SCOPE_SUBTREE, filter__, key__, NULL, 0, 0, 0, pg)) == -1) { @@ -433,6 +433,8 @@ ldap_query(const char *filter, const char *key, char **attributes, char ***outp, pg = m->page; aldap_freemsg(m); m = NULL; + if (found == -1) + found = 0; break; } if (m->message_type != LDAP_RES_SEARCH_ENTRY) @@ -447,7 +449,7 @@ ldap_query(const char *filter, const char *key, char **attributes, char ***outp, } } while (pg != NULL); - ret = found ? 1 : 0; + ret = found; goto end; error: -- 2.39.2