From fecf701a01cb96cf000f2a00d1435ee8e11848b4 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 2 Aug 2016 15:20:35 +0200 Subject: [PATCH 1/3] SDAP: sanitize member name before using in filter It caused an errors. (Tue Aug 2 06:29:39 2016) [sssd[be[LDAP]]] [sysdb_cache_search_users] (0x2000): Search users with filter: (&(objectclass=user)(nameAlias=t(u)ser@ldap)) (Tue Aug 2 06:29:39 2016) [sssd[be[LDAP]]] [sysdb_cache_search_users] (0x0080): Error: 5 (Input/output error) --- src/providers/ldap/sdap_async_groups.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index 102c1c0384be6da8732d56b7a318ded5a5132360..f19b68b8c403734f88b51a411ba0d009977d3491 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -1501,6 +1501,7 @@ sdap_process_missing_member_2307(struct sdap_process_group_state *state, const char *filter; const char *username; const char *user_dn; + char *sanitized_name; size_t count; struct ldb_message **msgs = NULL; static const char *attrs[] = { SYSDB_NAME, NULL }; @@ -1508,8 +1509,16 @@ sdap_process_missing_member_2307(struct sdap_process_group_state *state, tmp_ctx = talloc_new(NULL); if (!tmp_ctx) return ENOMEM; + ret = sss_filter_sanitize(tmp_ctx, member_name, &sanitized_name); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to sanitize the given name:'%s'.\n", member_name); + goto done; + } + /* Check for the alias in the sysdb */ - filter = talloc_asprintf(tmp_ctx, "(%s=%s)", SYSDB_NAME_ALIAS, member_name); + filter = talloc_asprintf(tmp_ctx, "(%s=%s)", SYSDB_NAME_ALIAS, + sanitized_name); if (!filter) { ret = ENOMEM; goto done; -- 2.9.2