>From 8316eeec49069e07de0a0adb18b06e3bce5505af Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 15 Nov 2012 07:33:30 +0100 Subject: [PATCH 2/4] LDAP: Fix saving empty groups https://fedorahosted.org/sssd/ticket/1647 A logic bug in the LDAP provider causes an attempt to allocate a zero-length array for group members while processing an empty group. The allocation would return NULL and saving the empty group would fail. --- src/providers/ldap/sdap_async_groups.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index b461973bc2f73ac43d70e0e2693f122bfdc9f00f..45832774a3f85ebea1464ba6a86f4d5b39f1e31d 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -433,9 +433,11 @@ static int sdap_save_group(TALLOC_CTX *memctx, el->values = gh->values; el->num_values = gh->num_values; + cnt = el->num_values + el1->num_values; + DEBUG(SSSDBG_TRACE_FUNC, ("Group %s has %d members\n", name, cnt)); + /* Now process RFC2307bis ghost hash table */ - if (ghosts != NULL) { - cnt = el->num_values + el1->num_values; + if (cnt > 0) { el->values = talloc_realloc(attrs, el->values, struct ldb_val, cnt); if (el->values == NULL) { -- 1.8.0