From e294f7351b810ea9180b2e9e0cab47beab18ae25 Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Fri, 20 Sep 2019 15:51:38 +0200
Subject: [PATCH] providers/ipa/: add_v1_user_data() amended
Fixes few mistypes and compilation warning:
```
sssd-2.2.3/src/providers/ipa/ipa_s2n_exop.c:665:20: warning: 'gc' may be used uninitialized in this function [-Wmaybe-uninitialized]
attrs->ngroups = gc;
~~~~~~~~~~~~~~~^~~~
```
Related to https://pagure.io/SSSD/sssd/issue/4078
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 39e16cca441d4a6b3affe8f27372c26ed11ac81f)
---
src/providers/ipa/ipa_s2n_exop.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
index f1d5768ae..a07f73200 100644
--- a/src/providers/ipa/ipa_s2n_exop.c
+++ b/src/providers/ipa/ipa_s2n_exop.c
@@ -620,7 +620,8 @@ static errno_t add_v1_user_data(struct sss_domain_info *dom,
if (attrs->ngroups > 0) {
attrs->groups = talloc_zero_array(attrs, char *, attrs->ngroups + 1);
if (attrs->groups == NULL) {
- DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n");
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_zero_array failed.\n");
+ attrs->ngroups = 0;
ret = ENOMEM;
goto done;
}
@@ -639,8 +640,10 @@ static errno_t add_v1_user_data(struct sss_domain_info *dom,
if (domain != NULL) {
obj_domain = find_domain_by_name_ex(parent_domain, domain, true, SSS_GND_ALL_DOMAINS);
if (obj_domain == NULL) {
- DEBUG(SSSDBG_OP_FAILURE, "find_domain_by_name failed.\n");
- return ENOMEM;
+ DEBUG(SSSDBG_OP_FAILURE, "find_domain_by_name_ex failed.\n");
+ attrs->ngroups = gc;
+ ret = ENOMEM;
+ goto done;
} else if (sss_domain_get_state(obj_domain) == DOM_DISABLED) {
/* skipping objects from disabled domains */
DEBUG(SSSDBG_TRACE_ALL,
@@ -655,14 +658,15 @@ static errno_t add_v1_user_data(struct sss_domain_info *dom,
attrs->groups[gc] = sss_create_internal_fqname(attrs->groups,
name, obj_domain->name);
if (attrs->groups[gc] == NULL) {
- DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
+ DEBUG(SSSDBG_OP_FAILURE, "sss_create_internal_fqname failed.\n");
+ attrs->ngroups = gc;
ret = ENOMEM;
goto done;
}
gc++;
}
+ attrs->ngroups = gc;
}
- attrs->ngroups = gc;
tag = ber_peek_tag(ber, &ber_len);
DEBUG(SSSDBG_TRACE_ALL, "BER tag is [%d]\n", (int) tag);
--
2.20.1