dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0063-LDAP-Fix-storing-initgroups-for-users-with-no-supple.patch

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