ecs: moved guest ip notification handling location
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 5 Jun 2015 03:21:24 +0000 (12:21 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Fri, 5 Jun 2015 03:21:24 +0000 (12:21 +0900)
- minor refactoring

Change-Id: I79e3933f582587361b4e69728efb480d9eef3f85
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
tizen/src/ecs/ecs_msg_injector.c

index 422ade3..c0e7aa9 100644 (file)
@@ -822,7 +822,7 @@ static void show_error_popup(char* data)
 
 static void* push_pkgs_thread(void* args)
 {
-    char* pkg_data = strdup((char*)args);
+    char* pkg_data = (char*)args;
     char* data = strdup(pkg_data);
     if (pkg_data == NULL || data == NULL) {
         LOG_SEVERE("pkg data strdup is failed.\n");
@@ -849,12 +849,17 @@ static void* push_pkgs_thread(void* args)
 
 static void do_package(char* cat, type_action action, const char* data)
 {
+    if (data == NULL || strlen(data) <= 0) {
+        LOG_SEVERE("data is corrupted.\n");
+        return;
+    }
+
     if (action == 1) {
         LOG_INFO("[pkgs] Already installed: %s\n", data);
     } else if (action == 2) {
         LOG_INFO("[pkgs] Needed to install: %s\n", data);
-        char pkgs[MAX_PKGS_LIST];
-        strcpy(pkgs, data);
+        char* pkgs = g_malloc0(MAX_PKGS_LIST);
+        strncpy(pkgs, data, MAX_PKGS_LIST - 1);
         qemu_thread_create(&sdb_thread_id, "sdb_push", push_pkgs_thread, (void*)pkgs, QEMU_THREAD_DETACHED);
     } else if (action == 3) {
         LOG_INFO("[pkgs] Package Installation Success: %s\n", data);
@@ -884,8 +889,15 @@ static bool injector_req_handle(char* cat, type_action action, const char* data)
     } else if (!strcmp(cat, MSG_TYPE_PACKAGE)) {
         do_package(cat, action, data);
         return true;
+    } else if (!strcmp(cat, MSG_TYPE_GUESTIP)) {
+        if (data != NULL && strlen(data) > 0) {
+            LOG_INFO("guest ip: %s\n", data);
+            set_emul_guest_ip((char*)data);
+        } else {
+            LOG_SEVERE("guest ip is null!\n");
+        }
+        return true;
     }
-
     return false;
 }
 
@@ -916,16 +928,7 @@ bool send_injector_ntf(const char* data, const int len)
     }
 
     TRACE("<< header cat = %s, length = %d, action=%d, group=%d\n", cat, length,action, group);
-    if (!strcmp(cat, MSG_TYPE_GUESTIP)) {
-        if (length > 0) {
-            INFO("guest ip: %s\n", (char*)ijdata);
-            set_emul_guest_ip((char*)ijdata);
-            return true;
-        } else {
-            ERR("guest ip is null!\n");
-            return false;
-        }
-    }
+
     ECS__Master master = ECS__MASTER__INIT;
     ECS__InjectorNtf ntf = ECS__INJECTOR_NTF__INIT;