svace:handling wrong policy syntax 23/108523/1
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Thu, 5 Jan 2017 03:22:57 +0000 (12:22 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Thu, 5 Jan 2017 03:23:13 +0000 (12:23 +0900)
Change-Id: I8871c77bf5f58ad89885c128f96442ce009197a8
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/internal/policy.cpp

index d4ab166..3bc5fce 100644 (file)
@@ -19,6 +19,9 @@ static const char* message_dir[] = { "ANY", "SEND", "RECEIVE"};
 static const char* message_decision[] = {"NO_DECISION", "ALLOW", "DENY", "CHECK"};
 
 static MessageType __str_to_message_type(const char* str) {
+       if (!str)
+               return MessageType::ANY;
+
        if (!std::strcmp(str, "method_call"))
                return MessageType::METHOD_CALL;
        else if (!std::strcmp(str, "method_return"))
@@ -113,23 +116,22 @@ void DbAdapter::updateDecision(const boost::property_tree::ptree::value_type& v,
                if (v.second.data() != "*")
                        value = v.second.data().c_str();
 
-               if (v.first == "context") {
-                       if (std::strcmp(value, "mandatory") == 0 ) {
-                               policy_type = PolicyType::CONTEXT;
-                               policy_type_value.context = ContextType::MANDATORY;
-                       } else if (std::strcmp(value, "default") == 0) {
-                               policy_type = PolicyType::CONTEXT;
-                               policy_type_value.context = ContextType::DEFAULT;
+               if (value) {
+                       if (v.first == "context") {
+                               if (std::strcmp(value, "mandatory") == 0 ) {
+                                       policy_type = PolicyType::CONTEXT;
+                                       policy_type_value.context = ContextType::MANDATORY;
+                               } else if (std::strcmp(value, "default") == 0) {
+                                       policy_type = PolicyType::CONTEXT;
+                                       policy_type_value.context = ContextType::DEFAULT;
+                               }
+                       } else if (v.first == "user") {
+                               policy_type = PolicyType::USER;
+                               policy_type_value.user = convertToUid(value);
+                       } else if (v.first == "group") {
+                               policy_type = PolicyType::GROUP;
+                               policy_type_value.group = convertToGid(value);
                        }
-               } else if (v.first == "user") {
-                       policy_type = PolicyType::USER;
-                       policy_type_value.user = convertToUid(value);
-               } else if (v.first == "group") {
-                       policy_type = PolicyType::GROUP;
-                       policy_type_value.group = convertToGid(value);
-               } else {
-                       attr = false;
-                       t = NONE;
                }
        } else if (attr && t == ALLOW_DENY_CHECK) {
                if (v.second.data() != "*")