summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena Reshetova <elena.reshetova@intel.com>2013-07-23 16:37:05 +0300
committerAnas Nashif <anas.nashif@intel.com>2013-08-05 12:53:17 -0400
commit7b74c9857bd55f28c62450d6aa7efc9a99b86bf1 (patch)
tree473bdd1d4454dde42469699d9ea0d5fc8fe10e3c
parent891fa8079b446e51e1f86583c6972249bbea053d (diff)
downloadrpm-7b74c9857bd55f28c62450d6aa7efc9a99b86bf1.tar.gz
rpm-7b74c9857bd55f28c62450d6aa7efc9a99b86bf1.tar.bz2
rpm-7b74c9857bd55f28c62450d6aa7efc9a99b86bf1.zip
Security plugin: pkg_name allocation in conflict
- fix to the pkg_name allocation in conflict handling
-rw-r--r--plugins/msm-plugin.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/msm-plugin.c b/plugins/msm-plugin.c
index f9213293b..4cb5ec3b0 100644
--- a/plugins/msm-plugin.c
+++ b/plugins/msm-plugin.c
@@ -209,14 +209,15 @@ rpmRC PLUGINHOOK_FILE_CONFLICT_FUNC(rpmts ts, char* path,
{
fileconflict *fc;
if (!path)
- return rpmrc;
+ return rpmrc;
+
rpmlog(RPMLOG_DEBUG, "FILE_CONFLICT_FUNC hook path %s\n",path);
- const char *name = headerGetString(oldHeader, RPMTAG_SECSWSOURCE);
- if (!name || !root) {
- return rpmrc; /* no sw source(s) - abnormal state */
- }
+ const char *name = headerGetString(oldHeader, RPMTAG_SECSWSOURCE);
const char *pkg_name = headerGetString(oldHeader, RPMTAG_NAME);
+ if (!name || !root || !pkg_name) {
+ return rpmrc; /* no sw source(s) or package name - abnormal state */
+ }
sw_source_x *sw_source = msmSWSourceTreeTraversal(root->sw_sources, findSWSourceByName, (void *)name, NULL);
if (!sw_source)
@@ -229,7 +230,8 @@ rpmRC PLUGINHOOK_FILE_CONFLICT_FUNC(rpmts ts, char* path,
if (!fc) return RPMRC_FAIL;
fc->path = path;
fc->sw_source = sw_source;
- fc->pkg_name = pkg_name;
+ fc->pkg_name = strdup(pkg_name);
+ if (!fc->pkg_name) return RPMRC_FAIL;
HASH_ADD_KEYPTR(hh, allfileconflicts, path, strlen(path), fc);
} else {
/* Many packages have installed the same file */
@@ -830,6 +832,7 @@ rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
HASH_ITER(hh, allfileconflicts, fc, temp) {
HASH_DELETE(hh, allfileconflicts, fc);
msmFreePointer((void**)&fc->path);
+ msmFreePointer((void**)&fc->pkg_name);
msmFreePointer((void**)&fc);
}
}