diff options
author | Sumit Bose <sbose@redhat.com> | 2014-10-01 16:19:18 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-10-14 18:24:55 +0200 |
commit | abee3216261e3378430e472f0c992470b33976f0 (patch) | |
tree | c135126bf301073e808b7764bbcc2ee6b0f21405 /src/providers | |
parent | 7a153394bdeb77325b7e4ee1502a1e89fa306f5a (diff) | |
download | sssd-abee3216261e3378430e472f0c992470b33976f0.tar.gz sssd-abee3216261e3378430e472f0c992470b33976f0.tar.xz sssd-abee3216261e3378430e472f0c992470b33976f0.zip |
add_v1_group_data: fix for empty members list
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/ipa/ipa_s2n_exop.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c index 148778918..0d5c35678 100644 --- a/src/providers/ipa/ipa_s2n_exop.c +++ b/src/providers/ipa/ipa_s2n_exop.c @@ -620,28 +620,37 @@ static errno_t add_v1_group_data(BerElement *ber, struct resp_attrs *attrs) goto done; } - for (attrs->ngroups = 0; list[attrs->ngroups] != NULL; - attrs->ngroups++); + if (list != NULL) { + for (attrs->ngroups = 0; list[attrs->ngroups] != NULL; + attrs->ngroups++); + + if (attrs->ngroups > 0) { + attrs->a.group.gr_mem = talloc_zero_array(attrs, char *, + attrs->ngroups + 1); + if (attrs->a.group.gr_mem == NULL) { + DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n"); + ret = ENOMEM; + goto done; + } - if (attrs->ngroups > 0) { - attrs->a.group.gr_mem = talloc_zero_array(attrs, char *, - attrs->ngroups + 1); + for (c = 0; c < attrs->ngroups; c++) { + attrs->a.group.gr_mem[c] = + talloc_strdup(attrs->a.group.gr_mem, + list[c]); + if (attrs->a.group.gr_mem[c] == NULL) { + DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n"); + ret = ENOMEM; + goto done; + } + } + } + } else { + attrs->a.group.gr_mem = talloc_zero_array(attrs, char *, 1); if (attrs->a.group.gr_mem == NULL) { DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n"); ret = ENOMEM; goto done; } - - for (c = 0; c < attrs->ngroups; c++) { - attrs->a.group.gr_mem[c] = - talloc_strdup(attrs->a.group.gr_mem, - list[c]); - if (attrs->a.group.gr_mem[c] == NULL) { - DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n"); - ret = ENOMEM; - goto done; - } - } } tag = ber_peek_tag(ber, &ber_len); |