From: Elena Reshetova Date: Tue, 23 Jul 2013 13:37:05 +0000 (+0300) Subject: Security plugin: pkg_name allocation in conflict X-Git-Tag: submit/tizen/20130805.171417~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b74c9857bd55f28c62450d6aa7efc9a99b86bf1;p=platform%2Fupstream%2Frpm.git Security plugin: pkg_name allocation in conflict - fix to the pkg_name allocation in conflict handling --- diff --git a/plugins/msm-plugin.c b/plugins/msm-plugin.c index f921329..4cb5ec3 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); } }