diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-08-27 09:42:36 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-08-27 09:50:57 +0200 |
commit | 2bbfa5226884573def1b40e9b22abde6bc349e3c (patch) | |
tree | 5ed17b5f9dec9a68c752ff7638d488f9ea3f2076 /src | |
parent | 9dfd17e0b153e02579009edc4d42212f86ba5ec2 (diff) | |
download | openlmi-providers-2bbfa5226884573def1b40e9b22abde6bc349e3c.tar.gz openlmi-providers-2bbfa5226884573def1b40e9b22abde6bc349e3c.tar.xz openlmi-providers-2bbfa5226884573def1b40e9b22abde6bc349e3c.zip |
logicalfile: coverity fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/logicalfile/LMI_DirectoryContainsFileProvider.c | 9 |
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"); } |