summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2014-05-14 12:31:24 +0200
committerTomas Bzatek <tbzatek@redhat.com>2014-05-15 16:09:14 +0200
commit09c52ea4b5d3f94bd20dec9baafcdbc05b87f9e8 (patch)
treed52b8a8163d70195da5f2bae00fcec2fa8bcbf84
parent7157f1e747be26346b06797ae0c97cf022bcd3ab (diff)
downloadopenlmi-providers-09c52ea4b5d3f94bd20dec9baafcdbc05b87f9e8.tar.gz
openlmi-providers-09c52ea4b5d3f94bd20dec9baafcdbc05b87f9e8.tar.xz
openlmi-providers-09c52ea4b5d3f94bd20dec9baafcdbc05b87f9e8.zip
account: Make LMI_MemberOfGroup.CreateInstance() more robust
Return proper error when required properties are not set. https://fedorahosted.org/openlmi/ticket/270
-rw-r--r--src/account/LMI_MemberOfGroupProvider.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/account/LMI_MemberOfGroupProvider.c b/src/account/LMI_MemberOfGroupProvider.c
index 4928f4d..d62d016 100644
--- a/src/account/LMI_MemberOfGroupProvider.c
+++ b/src/account/LMI_MemberOfGroupProvider.c
@@ -168,15 +168,30 @@ static CMPIStatus LMI_MemberOfGroupCreateInstance(
struct lu_context *luc = NULL;
struct lu_error *error = NULL;
+ CMPIObjectPath *collection_ref;
+ CMPIObjectPath *member_ref;
CMPIrc rc = CMPI_RC_OK;
char *errmsg = NULL;
int pwdlockres;
+#define GET_REF(PROP_NAME, REF) \
+ { \
+ CMPIStatus rcs = { CMPI_RC_OK, NULL }; \
+ CMPIData d = CMGetProperty(ci, PROP_NAME, &rcs); \
+ if (rcs.rc != CMPI_RC_OK || (d.state & CMPI_nullValue) == CMPI_nullValue || \
+ (d.state & CMPI_notFound) == CMPI_notFound || d.value.ref == NULL) \
+ KReturn2(_cb, ERR_INVALID_PARAMETER, "Required argument '%s' not set.", PROP_NAME);\
+ REF = d.value.ref; \
+ }
+
+ GET_REF("Collection", collection_ref);
+ GET_REF("Member", member_ref);
+
+#undef GET_REF
+
LMI_MemberOfGroup_InitFromObjectPath(&lmog, _cb, cop);
- LMI_GroupRef_InitFromObjectPath(&lg_ref, _cb,
- CMGetProperty(ci, "Collection", NULL).value.ref);
- LMI_IdentityRef_InitFromObjectPath(&li_ref, _cb,
- CMGetProperty(ci, "Member", NULL).value.ref);
+ LMI_GroupRef_InitFromObjectPath(&lg_ref, _cb, collection_ref);
+ LMI_IdentityRef_InitFromObjectPath(&li_ref, _cb, member_ref);
if (!(instances = CBAssociators(_cb, cc,
LMI_IdentityRef_ToObjectPath(&li_ref, NULL),