From e84b8e754f007cd94d9b535d562d8d315f692e8f Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 8 Jul 2016 13:19:31 +0200 Subject: [PATCH 63/74] LDAP: Fix storing initgroups for users with no supplementary groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there are no supplementary groups, we tried to qualify a NULL pointer to an array which resulted in an error. Reviewed-by: Lukáš Slebodník --- src/providers/ldap/sdap_async_initgroups.c | 32 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c index 7029427724cc37a4508e11ef5448b421e94dc787..cc63dff781338e33a9802f97d98174fce2167b4b 100644 --- a/src/providers/ldap/sdap_async_initgroups.c +++ b/src/providers/ldap/sdap_async_initgroups.c @@ -301,13 +301,15 @@ int sdap_initgr_common_store(struct sysdb_ctx *sysdb, /* Find the differences between the sysdb and LDAP lists * Groups in the sysdb only must be removed. */ - ldap_fqdnlist = sss_create_internal_fqname_list( - tmp_ctx, - (const char * const *) ldap_grouplist, - domain->name); - if (ldap_fqdnlist == NULL) { - ret = ENOMEM; - goto done; + if (ldap_grouplist != NULL) { + ldap_fqdnlist = sss_create_internal_fqname_list( + tmp_ctx, + (const char * const *) ldap_grouplist, + domain->name); + if (ldap_fqdnlist == NULL) { + ret = ENOMEM; + goto done; + } } ret = diff_string_lists(tmp_ctx, ldap_fqdnlist, sysdb_grouplist, @@ -1288,13 +1290,15 @@ sdap_initgr_store_user_memberships(struct sdap_initgr_nested_state *state) } } - ldap_fqdnlist = sss_create_internal_fqname_list( - tmp_ctx, - (const char * const *) ldap_parent_name_list, - state->dom->name); - if (ldap_fqdnlist == NULL) { - ret = ENOMEM; - goto done; + if (ldap_parent_name_list) { + ldap_fqdnlist = sss_create_internal_fqname_list( + tmp_ctx, + (const char * const *) ldap_parent_name_list, + state->dom->name); + if (ldap_fqdnlist == NULL) { + ret = ENOMEM; + goto done; + } } ret = sysdb_get_direct_parents(tmp_ctx, state->dom, SYSDB_MEMBER_USER, -- 2.4.11