Empty PID string means no filtering by PID is needed.
Change-Id: Id593504d59db4a3fe53c4d3d8aa62be235027219
Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
}
}
+static int is_pid_string_valid(const char *pid_str)
+{
+ char *tmp;
+ long pid;
+
+ if (pid_str[0] == '\0') /* no pid filtering */
+ return 1;
+
+ /* otherwise this should be a valid number */
+ pid = strtol(pid_str, &tmp, 10);
+
+ /* TODO: get max pid value from /proc/sys/kernel/pid_max */
+ return *tmp == '\0' && pid > 0 && pid <= 32768;
+}
+
int check_app_id(uint32_t app_type, char *app_id)
{
int res = 0;
res = 1;
break;
case APP_TYPE_RUNNING:
- strtol(app_id, &p, 10);
- if ((*app_id != 0) && (*p == 0))
- res = 1;
- else
+ if (!is_pid_string_valid(app_id))
LOGE("wrong app id for APP_RUNNING\n");
+ else
+ res = 1;
break;
case APP_TYPE_COMMON:
res = (strlen(app_id) == 0);
res = kill_app(app_info->exe_path);
break;
case APP_TYPE_WEB:
- /* do nothing (it is restarted by itself */
+ /* do nothing (it is restarted by itself) */
break;
default:
LOGE("Unknown app type %d\n", app_info->app_type);
} else { /* child */
execl(WRT_LAUNCHER_PATH,
WRT_LAUNCHER_NAME,
- WRT_LAUNCHER_LAUNCH,
+ WRT_LAUNCHER_START,
app_id,
NULL);
/* FIXME: If code flows here, it deserves greater attention */
#define LAUNCH_APP_PATH "/usr/bin/launch_app"
#define KILL_APP_PATH "/usr/bin/pkill"
#define LAUNCH_APP_NAME "launch_app"
-#define WRT_LAUNCHER_PATH "/usr/bin/wrt-launcher"
-#define WRT_LAUNCHER_NAME "wrt-launcher"
-#define WRT_LAUNCHER_LAUNCH "-s"
-#define WRT_LAUNCHER_KILL "-k"
+#define WRT_LAUNCHER_PATH "/usr/bin/wrt-launcher"
+#define WRT_LAUNCHER_NAME "wrt-launcher"
+#define WRT_LAUNCHER_START "-s"
+#define WRT_LAUNCHER_KILL "-k"
#define LAUNCH_APP_SDK "__AUL_SDK__"
#define DA_PRELOAD_EXEC "DYNAMIC_ANALYSIS"
#define DA_PRELOAD(AppType) AppType ? DA_PRELOAD_OSP : DA_PRELOAD_TIZEN