Fix defects detected by static analysis tool 82/174582/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 3 Apr 2018 06:04:00 +0000 (15:04 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 3 Apr 2018 06:04:05 +0000 (15:04 +0900)
Change-Id: I291830b6ad35b1759cbe110bba605d90c584c185

ism/extras/efl_panel/isf_panel_efl.cpp
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.h
ism/src/scim_helper_launcher.cpp
ism/src/scim_utility.h

index 321addc..44c51e0 100644 (file)
@@ -7697,7 +7697,7 @@ int main (int argc, char *argv [])
                 ret = -1;
                 goto cleanup;
             }
-            DebugOutput::set_output (String (argv [i]));
+            DebugOutput::set_output (sanitize_string (argv [i]));
             continue;
         }
 
index 61a3b0f..38c4d29 100644 (file)
@@ -2094,7 +2094,7 @@ private:
                     } else if (cmd == ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE) {
                         uint32 disabled;
                         bool ret = true;
-                        m_info_manager->get_ise_return_key_disable(client_id, disabled);
+                        ret = m_info_manager->get_ise_return_key_disable(client_id, disabled);
                         Transaction trans;
                         Socket client_socket(client_id);
 
index a23b14a..bc330fd 100644 (file)
@@ -1157,6 +1157,7 @@ public:
             get_focused_context (client, context);
             ctx = get_helper_ic (client, context);
             m_panel_agent_manager.get_helper_return_key_type (it->second.id, ctx, uuid, type);
+            return true;
         }
 
         return false;
@@ -1188,6 +1189,7 @@ public:
             get_focused_context (client, context);
             ctx = get_helper_ic (client, context);
             m_panel_agent_manager.get_helper_return_key_disable (it->second.id, ctx, uuid, disabled);
+            return true;
         }
 
         return false;
@@ -1897,11 +1899,14 @@ public:
             set_helper_return_key_disable (m_current_helper_uuid, disabled);
     }
     //ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE
-    void get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled) {
+    bool get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled) {
         SCIM_DEBUG_MAIN (4) << __func__ << "\n";
+        bool   ret  = false;
 
         if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
-            get_helper_return_key_disable (m_current_helper_uuid, disabled);
+            ret = get_helper_return_key_disable (m_current_helper_uuid, disabled);
+
+        return ret;
     }
 
     void reset_helper_context (const String& uuid) {
@@ -4779,9 +4784,9 @@ void InfoManager::set_ise_return_key_disable (int client_id, uint32 disabled)
 }
 
 //ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE
-void InfoManager::get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled)
+bool InfoManager::get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled)
 {
-    m_impl->get_ise_return_key_disable (client_id, disabled);
+    return m_impl->get_ise_return_key_disable (client_id, disabled);
 }
 
 //ISM_TRANS_CMD_SET_CAPS_MODE
index 485f00e..5464c95 100644 (file)
@@ -709,7 +709,7 @@ public:
     void set_ise_return_key_disable (int client_id, uint32 disabled);
 
     //ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE
-    void get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled);
+    bool get_ise_return_key_disable (int client_id, _OUT_ uint32& disabled);
 
     //ISM_TRANS_CMD_SET_CAPS_MODE
     void set_ise_caps_mode (int client_id, uint32 mode);
index 5e16524..ad720f2 100644 (file)
 #include "scim_private.h"
 #include "scim.h"
 #include <unistd.h>
+#include <string.h>
 
 using namespace scim;
 
+static String sanitize_string (const char *str, int maxlen = 32)
+{
+    String ret;
+    static char acceptables[] =
+        "abcdefghijklmnopqrstuvwxyz"
+        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+        "1234567890_-.@:";
+
+    char *newstr = NULL;
+    if (maxlen > 0) {
+        newstr = new char[maxlen + 1];
+    }
+    int len = 0;
+    if (newstr) {
+        memset (newstr, 0x00, sizeof (char) * (maxlen + 1));
+
+        if (str) {
+            while (len < maxlen && str[len] != '\0' && strchr (acceptables, str[len]) != NULL) {
+                newstr[len] = str[len];
+                len++;
+            }
+            ret = newstr;
+        }
+        delete [] newstr;
+    }
+    return ret;
+}
+
 int main (int argc, char *argv [])
 {
     int i = 0;
@@ -130,7 +159,7 @@ int main (int argc, char *argv [])
                 std::cerr << "No argument for option " << argv [i-1] << "\n";
                 return -1;
             }
-            DebugOutput::set_output (String (argv [i]));
+            DebugOutput::set_output (sanitize_string (argv [i]));
             continue;
         }
 
@@ -145,7 +174,7 @@ int main (int argc, char *argv [])
         }
     }
 
-    String exec = argv[0];
+    String exec = sanitize_string (argv[0]);
 
     if (exec != String (SCIM_HELPER_LAUNCHER_PROGRAM)) {
         /* 3rd party shared object type IME */
index 8608ce5..a007992 100644 (file)
@@ -529,7 +529,6 @@ typedef enum
 #define mzc_normal                      mzsc(0m)
 #define mzc_red                         mzsc(1;31m)
 
-
 /** @} */
 } /* namespace scim */