Check executable file 55/248455/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Nov 2020 22:36:24 +0000 (07:36 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 26 Nov 2020 22:36:24 +0000 (07:36 +0900)
If an app_path is not executable, launchpad rejects the launch request.

Change-Id: I2ae28b5c1852cb2d500d323fbbc2c4016f0f9720
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/src/launchpad.c

index df329e7..78399c9 100644 (file)
@@ -753,7 +753,7 @@ static int __real_send(int clifd, int ret)
        return 0;
 }
 
-static void __send_result_to_caller(int clifd, int ret, const char *app_path)
+static void __send_result_to_caller(int clifd, int ret)
 {
        _W("send result: %d", ret);
 
@@ -2204,21 +2204,38 @@ static bool __handle_launch_event(int fd, io_condition_e cond, void *data)
        menu_info = _appinfo_create(kb);
        if (menu_info == NULL) {
                _E("such pkg no found");
+               __send_result_to_caller(clifd, -EINVAL);
+               clifd = -1;
                goto end;
        }
 
        app_path = _appinfo_get_app_path(menu_info);
        if (app_path == NULL) {
                _E("app_path is NULL");
+               __send_result_to_caller(clifd, -EINVAL);
+               clifd = -1;
                goto end;
        }
+
        if (app_path[0] != '/') {
                _E("app_path is not absolute path");
+               __send_result_to_caller(clifd, -EINVAL);
+               clifd = -1;
+               goto end;
+       }
+
+       if (access(app_path, X_OK) != 0) {
+               ret = -errno;
+               _E("%s is not executable. errno(%d)", app_path, errno);
+               __send_result_to_caller(clifd, ret);
+               clifd = -1;
                goto end;
        }
 
        if (menu_info->hwacc == NULL) {
                _E("[launchpad] Failed to find H/W acceleration type");
+               __send_result_to_caller(clifd, -EINVAL);
+               clifd = -1;
                goto end;
        }
 
@@ -2261,6 +2278,8 @@ static bool __handle_launch_event(int fd, io_condition_e cond, void *data)
        _modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
        if (menu_info->appid == NULL) {
                _E("unable to get appid from menu_info");
+               __send_result_to_caller(clifd, -EINVAL);
+               clifd = -1;
                goto end;
        }
 
@@ -2287,7 +2306,7 @@ static bool __handle_launch_event(int fd, io_condition_e cond, void *data)
        }
 
        _memory_monitor_reset_timer();
-       __send_result_to_caller(clifd, pid, app_path);
+       __send_result_to_caller(clifd, pid);
        clifd = -1;
 end:
        if (clifd != -1)