svace 62/74462/1 accepted/tizen/common/20160616.151834 accepted/tizen/ivi/20160616.105231 accepted/tizen/mobile/20160616.105143 accepted/tizen/tv/20160616.105202 accepted/tizen/wearable/20160616.105218 submit/tizen/20160616.032706
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 14 Jun 2016 09:04:05 +0000 (18:04 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 14 Jun 2016 09:04:16 +0000 (18:04 +0900)
Change-Id: I745773662dc8578fce7590bd1b3bc2bde3ede5ed
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/internal/naive_policy_checker.cpp
src/internal/policy.cpp
src/libdbuspolicy1.c

index 8fc311a..6489a6d 100644 (file)
@@ -60,7 +60,7 @@ bool NaivePolicyChecker::parseDecision(Decision decision,
        case Decision::DENY:
                return false;
        case Decision::CHECK:
-               std::sprintf(uid_str, "%lu", (unsigned long)uid);
+               std::snprintf(uid_str, sizeof(uid_str) - 1, "%lu", (unsigned long)uid);
                return ldp_cynara::Cynara::check(label, privilege, uid_str) == ldp_cynara::CynaraResult::ALLOW;
        }
 
index da65a5c..20076e5 100644 (file)
@@ -59,7 +59,7 @@ uid_t DbAdapter::convertToUid(const char* user) {
        struct passwd pwent;
        struct passwd *pwd;
        char buf[1024];
-       if (getpwnam_r(user, &pwent, buf, sizeof(buf), &pwd) && pwd)
+       if (getpwnam_r(user, &pwent, buf, sizeof(buf), &pwd) || !pwd)
                return (uid_t)-1;
 
        return pwd->pw_uid;
@@ -73,7 +73,7 @@ gid_t DbAdapter::convertToGid(const char* group) {
        struct group grent;
        struct group *gg;
        char buf[1024];
-       if (getgrnam_r(group, &grent, buf, sizeof(buf), &gg) && gg)
+       if (getgrnam_r(group, &grent, buf, sizeof(buf), &gg) || !gg)
                return (gid_t)-1;
 
        return gg->gr_gid;
@@ -259,6 +259,9 @@ ItemType ItemOwn::getType() const {
 }
 bool ItemOwn::match(const Item* item) const {
        const ItemOwn* it = dynamic_cast<const ItemOwn*>(item);
+       if (!it)
+               return false;
+
        if (__is_prefix) {
                int i = 0;
                if (!__name)
@@ -339,6 +342,9 @@ ItemSendReceive::~ItemSendReceive() {
 bool ItemSendReceive::match(const Item* item) const {
        const ItemSendReceive* it = dynamic_cast<const ItemSendReceive*>(item);
 
+       if (!it)
+               return false;
+
        if (__type != MessageType::ANY && __type != it->__type)
                return false;
 
index c274833..867ce2e 100644 (file)
@@ -107,7 +107,7 @@ static uint64_t kdbus_unique_id(char const *name)
        unsigned i = 2;
        int c;
        while (!(c = name[++i] - '0'));
-       res = c;
+       res = (uint64_t)c;
        while ((c = (int)(name[++i]) - '0') > 0)
                res = res*10 + c;
        return res;