diff options
author | Jan Safranek <jsafrane@redhat.com> | 2013-11-14 12:17:49 +0100 |
---|---|---|
committer | Jan Safranek <jsafrane@redhat.com> | 2013-11-14 12:17:49 +0100 |
commit | fd36206ba36e169eaad9421b0e624feb02b5abff (patch) | |
tree | 1afb059dae2eb933a1b76f4c0509258663a0c3ab | |
parent | e4d26f8d9d7603d291abf23fe38d1ba401db6fb1 (diff) | |
download | openlmi-providers-fd36206ba36e169eaad9421b0e624feb02b5abff.tar.gz openlmi-providers-fd36206ba36e169eaad9421b0e624feb02b5abff.tar.xz openlmi-providers-fd36206ba36e169eaad9421b0e624feb02b5abff.zip |
logicalfile: don't assume 'Name' property is available before checking the class
The provider must not crash when Associators and/or References is called
with odd object path - it does not need to be LMI_UnixDirectory or
CIM_LogicalFile.
-rw-r--r-- | src/logicalfile/LMI_DirectoryContainsFileProvider.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/logicalfile/LMI_DirectoryContainsFileProvider.c b/src/logicalfile/LMI_DirectoryContainsFileProvider.c index e1fd8c9..40fa567 100644 --- a/src/logicalfile/LMI_DirectoryContainsFileProvider.c +++ b/src/logicalfile/LMI_DirectoryContainsFileProvider.c @@ -167,8 +167,6 @@ static CMPIStatus associators( CMReturn(CMPI_RC_OK); } - path = get_string_property_from_op(cop, "Name"); - if (CMClassPathIsA(_cb, cop, LMI_UnixDirectory_ClassName, &st)) { /* got UnixDirectory - GroupComponent */ st = lmi_check_required(_cb, cc, cop); @@ -182,6 +180,9 @@ static CMPIStatus associators( if (count > MAX_REFS) { CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Too many files in a single directory..."); } + path = get_string_property_from_op(cop, "Name"); + if (!path) + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided LMI_UnixDirectory"); /* TODO: directories are walked in two passes * rewrite using only one pass */ @@ -202,6 +203,9 @@ static CMPIStatus associators( if (group == 1 || rgroup == 0) { CMReturn(CMPI_RC_OK); } + path = get_string_property_from_op(cop, "Name"); + if (!path) + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided CIM_logicalFile"); st = check_assoc_class(_cb, ns, resultClass, LMI_UnixDirectory_ClassName); check_class_check_status(st); @@ -277,14 +281,16 @@ static CMPIStatus references( CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns); LMI_DirectoryContainsFile_Init(&lmi_dcf, _cb, ns); - path = get_string_property_from_op(cop, "Name"); get_class_from_path(path, ccname); - st = get_fsname_from_path(_cb, path, &fsname); - check_status(st); if (strcmp(ccname, LMI_UnixDirectory_ClassName) == 0) { st = lmi_check_required(_cb, cc, cop); check_status(st); + path = get_string_property_from_op(cop, "Name"); + if (!path) + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided LMI_UnixDirectory"); + st = get_fsname_from_path(_cb, path, &fsname); + check_status(st); /* got GroupComponent - DirectoryRef */ fill_logicalfile(CIM_DirectoryRef, &lmi_dr, path, fsname, LMI_UnixDirectory_ClassName); o = CIM_DirectoryRef_ToObjectPath(&lmi_dr, &st); @@ -314,6 +320,11 @@ static CMPIStatus references( } else if (strcmp(ccname, CIM_LogicalFile_ClassName) == 0) { st = lmi_check_required(_cb, cc, cop); check_status(st); + path = get_string_property_from_op(cop, "Name"); + if (!path) + CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, "Cannot find Name property in provided CIM_LogicalFile"); + st = get_fsname_from_path(_cb, path, &fsname); + check_status(st); /* got PartComponent - LogicalFileRef */ if (group == 1) { CMReturn(CMPI_RC_OK); @@ -327,7 +338,6 @@ static CMPIStatus references( /* GroupComponent */ char *aux = strdup(path); char *dir = dirname(aux); - char *fsname; st = get_fsname_from_path(_cb, dir, &fsname); if (st.rc != CMPI_RC_OK) { free(aux); @@ -348,7 +358,6 @@ static CMPIStatus references( free(aux); } else { /* this association does not associate with given 'cop' class */ - free(fsname); CMReturn(CMPI_RC_OK); } |