From 7b74c9857bd55f28c62450d6aa7efc9a99b86bf1 Mon Sep 17 00:00:00 2001 From: Elena Reshetova Date: Tue, 23 Jul 2013 16:37:05 +0300 Subject: Security plugin: pkg_name allocation in conflict - fix to the pkg_name allocation in conflict handling --- plugins/msm-plugin.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'plugins') 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); } } -- cgit v1.2.3