diff options
author | Jusung Son <jusung07.son@samsung.com> | 2020-02-25 11:30:47 +0900 |
---|---|---|
committer | HwanKyu Jhun <h.jhun@samsung.com> | 2020-02-25 03:55:49 +0000 |
commit | 726fdb6eb52f6e78912e59823a96a7f2a38bc058 (patch) | |
tree | 7f6687f1b1327f2dc7faf1ac47099bc5fb02ac6f | |
parent | acc6be19d391a3d71c63ddbb8e4fa9b91aa91dfe (diff) | |
download | launchpad-726fdb6eb52f6e78912e59823a96a7f2a38bc058.tar.gz launchpad-726fdb6eb52f6e78912e59823a96a7f2a38bc058.tar.bz2 launchpad-726fdb6eb52f6e78912e59823a96a7f2a38bc058.zip |
Fix char overflow
char type_str[0] = '0' + LAUNCHPAD_LOADER_TYPE_DYNAMIC = 48 + 100 = -108
Change-Id: Ifebba27e34d303fcdbaf5205471d39c91c1dbcbc
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
-rw-r--r-- | src/launchpad/src/launchpad.c | 6 | ||||
-rw-r--r-- | src/lib/src/launchpad_lib.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/launchpad/src/launchpad.c b/src/launchpad/src/launchpad.c index 4d8bbd3..3032e22 100644 --- a/src/launchpad/src/launchpad.c +++ b/src/launchpad/src/launchpad.c @@ -828,8 +828,8 @@ static int __hydra_send_launch_candidate_request(int fd) static int __prepare_candidate_process(int type, int loader_id) { int pid; - char type_str[2] = {0, }; - char loader_id_str[10] = {0, }; + char type_str[12] = {0, }; + char loader_id_str[12] = {0, }; char argbuf[LOADER_ARG_LEN]; char *argv[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; candidate_process_context_t *cpt = __find_slot(type, loader_id); @@ -847,8 +847,8 @@ static int __prepare_candidate_process(int type, int loader_id) cpt->last_exec_time = time(NULL); - type_str[0] = '0' + type; snprintf(loader_id_str, sizeof(loader_id_str), "%d", loader_id); + snprintf(type_str, sizeof(type_str), "%d", type); argv[LOADER_ARG_PATH] = cpt->loader_path; argv[LOADER_ARG_TYPE] = type_str; argv[LOADER_ARG_ID] = loader_id_str; diff --git a/src/lib/src/launchpad_lib.c b/src/lib/src/launchpad_lib.c index e2a75bc..45a59f9 100644 --- a/src/lib/src/launchpad_lib.c +++ b/src/lib/src/launchpad_lib.c @@ -405,7 +405,7 @@ API int launchpad_loader_main(int argc, char **argv, return -1; } - __loader_type = argv[LOADER_ARG_TYPE][0] - '0'; + __loader_type = atoi(argv[LOADER_ARG_TYPE]); if (__loader_type < 0 || __loader_type >= LAUNCHPAD_TYPE_MAX) { _E("invalid argument. (type: %d)", __loader_type); return -1; |