From: Zofia Abramowska Date: Sun, 2 Apr 2017 12:50:26 +0000 (+0200) Subject: Fix privilege info X-Git-Tag: submit/tizen/20170405.143506~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=447e87a30f9d0f761f3e48d6eb56f382f850c0e4;p=platform%2Fcore%2Fsecurity%2Faskuser.git Fix privilege info * Fix possible incorrect memory access (use after free) * Don't throw when privilege_info fails, return input parameter instead (behave like dgettext) Change-Id: Ia3ef07e06282a88c39d9a6dd98644f5bbda40dc9 --- diff --git a/src/common/policy/PrivilegeInfo.cpp b/src/common/policy/PrivilegeInfo.cpp index 1ab529e..06d65b7 100644 --- a/src/common/policy/PrivilegeInfo.cpp +++ b/src/common/policy/PrivilegeInfo.cpp @@ -49,7 +49,7 @@ std::string getPrivacyDisplayName(const std::string &privilege) { return privilege; } std::unique_ptr displaNamePtr(displayName, free); - return displayName; + return std::string(displayName); } std::string getPrivacyName(const std::string &privilege) { @@ -57,19 +57,20 @@ std::string getPrivacyName(const std::string &privilege) { int ret = privilege_info_get_privacy_by_privilege(privilege.c_str(), &privacyName); if (ret != PRVMGR_ERR_NONE || !privacyName) { ALOGE("Unable to get privacy group for privilege: <" << privilege << ">, err: <" << ret << ">"); - throw Exception("Can't get privacy group name for privilege " + privilege); + return privilege; } std::unique_ptr privacyNamePtr(privacyName, free); - return privacyName; + return std::string(privacyName); } + std::vector getPrivacyPrivileges(const std::string &privacy) { GList *privilegeList = nullptr; int ret = privilege_info_get_privilege_list_by_privacy(privacy.c_str(), &privilegeList); if (ret != PRVMGR_ERR_NONE || !privilegeList) { ALOGE("Unable to get privacy group list of privileges; err: <" << ret << ">" ); - return {}; + return {privacy}; } GListWrap privList(privilegeList);