Fix static analyzer issues 38/169238/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 5 Feb 2018 06:47:22 +0000 (15:47 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 5 Feb 2018 07:21:30 +0000 (07:21 +0000)
Change-Id: I4ee2dd2c1d90c17b45dfbac7019ebbfbda67d8bb
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
client/src/pkgmgr.c
installer/pkgmgr_installer_signal_agent.c

index 76b330b..d7e48cc 100644 (file)
@@ -236,12 +236,17 @@ static int __check_app_process(pkgmgr_request_service_type service_type,
                return PKGMGR_R_ERROR;
        }
 
-       if (service_type == PM_REQUEST_KILL_APP)
+       if (service_type == PM_REQUEST_KILL_APP) {
                ret = pkgmgr_client_connection_send_request(client, "kill",
                                g_variant_new("(us)", uid, pkgid), &result);
-       else if (service_type == PM_REQUEST_CHECK_APP)
+       } else if (service_type == PM_REQUEST_CHECK_APP) {
                ret = pkgmgr_client_connection_send_request(client, "check",
                                g_variant_new("(us)", uid, pkgid), &result);
+       } else {
+               ERR("unexpected service type: %d", service_type);
+               ret = PKGMGR_R_ERROR;
+       }
+
        if (ret != PKGMGR_R_OK) {
                ERR("request failed: %d", ret);
                return ret;
index f674379..9d5ebd9 100644 (file)
@@ -236,6 +236,12 @@ static gboolean __handle_signal(gint fd, GIOCondition cond, gpointer user_data)
                return FALSE;
        }
 
+       if (type_len == 0) {
+               LOGE("invalid type_len");
+               close(clifd);
+               return FALSE;
+       }
+
        /* get signal name (including terminating null byte) */
        type_name = malloc(type_len);
        memcpy(type_name, buf, type_len);