summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-01-15 17:31:18 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 20:55:58 +0100
commit6c05254865283a388f0eba926ef2a79fa7608452 (patch)
treee6efdb36cb9fa999f43132a742b8ec71a067de57 /src
parent024d6981d5f0f66cdf528c234b82e5856d917e92 (diff)
downloadsssd-6c05254865283a388f0eba926ef2a79fa7608452.tar.gz
sssd-6c05254865283a388f0eba926ef2a79fa7608452.tar.xz
sssd-6c05254865283a388f0eba926ef2a79fa7608452.zip
LDAP: avoid complex realloc logic in save_rfc2307bis_group_memberships
https://fedorahosted.org/sssd/ticket/1761 The function tried to be smart and realloc only when needed, but that only lead to hard-to find bugs where the logic would not allocate the proper space. Remove the reallocation and prefer readability over speed in this case.
Diffstat (limited to 'src')
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 66be76e66..e9d1f3cc9 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -1793,7 +1793,6 @@ save_rfc2307bis_group_memberships(struct sdap_initgr_rfc2307bis_state *state)
int num_added;
int i;
int grp_count;
- int grp_count_old = 0;
char **add = NULL;
tmp_ctx = talloc_new(NULL);
@@ -1833,12 +1832,10 @@ save_rfc2307bis_group_memberships(struct sdap_initgr_rfc2307bis_state *state)
* nesting limit. This array must be NULL terminated.
*/
for (grp_count = 0; iter->add[grp_count]; grp_count++);
- if (grp_count > grp_count_old) {
- add = talloc_realloc(tmp_ctx, add, char*, grp_count + 1);
- if (add == NULL) {
- ret = ENOMEM;
- goto done;
- }
+ add = talloc_zero_array(tmp_ctx, char *, grp_count + 1);
+ if (add == NULL) {
+ ret = ENOMEM;
+ goto done;
}
num_added = 0;
@@ -1852,11 +1849,6 @@ save_rfc2307bis_group_memberships(struct sdap_initgr_rfc2307bis_state *state)
}
}
- /* Swap old and new group counter. */
- grp_count ^= grp_count_old;
- grp_count_old ^= grp_count;
- grp_count ^= grp_count_old;
-
if (num_added == 0) {
add = NULL;
} else {