summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/logicalfile/LMI_DirectoryContainsFileProvider.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/logicalfile/LMI_DirectoryContainsFileProvider.c b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
index 25b9529..563e995 100644
--- a/src/logicalfile/LMI_DirectoryContainsFileProvider.c
+++ b/src/logicalfile/LMI_DirectoryContainsFileProvider.c
@@ -57,9 +57,8 @@ static CMPIStatus dir_file_objectpaths(
continue;
}
- char rpath[BUFLEN];
+ char rpath[BUFLEN + 1]; /* \0 */
char fileclass[BUFLEN];
- char *aux = strdup(path);
char *fsname;
if (!strcmp(de->d_name, "..")) {
@@ -69,6 +68,7 @@ static CMPIStatus dir_file_objectpaths(
if (group == 1 || rgroup == 0) {
continue;
}
+ char *aux = strdup(path);
strncpy(rpath, dirname(aux), BUFLEN);
free(aux);
} else {
@@ -84,6 +84,7 @@ static CMPIStatus dir_file_objectpaths(
}
if (lstat(rpath, &sb) < 0) {
+ closedir(dp);
char err[BUFLEN];
snprintf(err, BUFLEN, "Can't stat file: %s", rpath);
CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, err);
@@ -91,6 +92,7 @@ static CMPIStatus dir_file_objectpaths(
get_class_from_stat(&sb, fileclass);
check_assoc_class(_cb, namespace, resultClass, fileclass);
if (get_fsname_from_stat(&sb, &fsname) < 0) {
+ closedir(dp);
CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
}
}
@@ -105,6 +107,7 @@ static CMPIStatus dir_file_objectpaths(
free(fsname);
}
*count = i;
+ closedir(dp);
CMReturn(CMPI_RC_OK);
}
@@ -219,6 +222,7 @@ static CMPIStatus associators(
check_assoc_class(_cb, ns, resultClass, LMI_UnixDirectory_ClassName);
if (get_fsname_from_path(dir, &fsname) < 0) {
+ free(aux);
CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
}
fill_logicalfile(CIM_DirectoryRef, &lmi_dr, dir, fsname, LMI_UnixDirectory_ClassName);
@@ -332,6 +336,7 @@ static CMPIStatus references(
char *dir = dirname(aux);
char *fsname;
if (get_fsname_from_path(dir, &fsname) < 0) {
+ free(aux);
CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, "Can't get filesystem name");
}