From 9e9e9af8dda18847e71b1e24093acf3c6427bf11 Mon Sep 17 00:00:00 2001 From: cyee Date: Sat, 7 Nov 2020 14:03:12 -0800 Subject: [PATCH 1/2] VITA: fix crash when boot params is missing --- frontend/drivers/platform_psp.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index df6d109ffb..9ec8c7062d 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -342,25 +342,30 @@ static void frontend_psp_exec(const char *path, bool should_load_game) RARCH_LOG("Attempt to load executable: [%s].\n", path); #if defined(VITA) RARCH_LOG("Attempt to load executable: %d [%s].\n", args, argp); + int ret; #ifdef IS_SALAMANDER sceAppMgrGetAppParam(boot_params); if (strstr(boot_params,"psgm:play")) { - int ret; - char *param1 = strstr(boot_params, "¶m=")+7; + char *param1 = strstr(boot_params, "¶m="); char *param2 = strstr(boot_params, "¶m2="); - memcpy(core_name, param1, param2 - param1); - core_name[param2-param1] = 0; - sprintf(argp, param2 + 8); - ret = sceAppMgrLoadExec(core_name, (char * const*)((const char*[]){argp, 0}), NULL); - RARCH_LOG("Attempt to load executable: [%d].\n", ret); + if (param1 != NULL && param2 != NULL) + { + param1 += 7; + memcpy(core_name, param1, param2 - param1); + core_name[param2-param1] = 0; + sprintf(argp, param2 + 8); + ret = sceAppMgrLoadExec(core_name, (char * const*)((const char*[]){argp, 0}), NULL); + RARCH_LOG("Attempt to load executable: [%d].\n", ret); + goto exit; + } + RARCH_LOG("Required boot params missing. Continue nornal boot."); } - else #endif - { - int ret = sceAppMgrLoadExec(path, args == 0 ? NULL : (char * const*)((const char*[]){argp, 0}), NULL); - RARCH_LOG("Attempt to load executable: [%d].\n", ret); - } + ret = sceAppMgrLoadExec(path, args == 0 ? NULL : (char * const*)((const char*[]){argp, 0}), NULL); + RARCH_LOG("Attempt to load executable: [%d].\n", ret); +exit: + return; #else exitspawn_kernel(path, args, argp); #endif From 154130357408970ab491c4310ce88acf76451887 Mon Sep 17 00:00:00 2001 From: cyee Date: Sun, 8 Nov 2020 01:15:59 -0800 Subject: [PATCH 2/2] fix code review comment --- frontend/drivers/platform_psp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 9ec8c7062d..8072c3ce33 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -324,6 +324,7 @@ static void frontend_psp_exec(const char *path, bool should_load_game) #endif char argp[512] = {0}; SceSize args = 0; + int ret; #if !defined(VITA) strlcpy(argp, eboot_path, sizeof(argp)); @@ -342,7 +343,6 @@ static void frontend_psp_exec(const char *path, bool should_load_game) RARCH_LOG("Attempt to load executable: [%s].\n", path); #if defined(VITA) RARCH_LOG("Attempt to load executable: %d [%s].\n", args, argp); - int ret; #ifdef IS_SALAMANDER sceAppMgrGetAppParam(boot_params); if (strstr(boot_params,"psgm:play"))