From: Hwankyu Jhun Date: Mon, 22 Nov 2021 09:23:07 +0000 (+0900) Subject: Fix crash issue X-Git-Tag: submit/tizen/20211123.042050~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91c8a50b1948653765bccdf51166b8a0b88eaf7e;p=platform%2Fcore%2Fappfw%2Famd.git Fix crash issue If the s1 argument of the strcmp() is nullptr, the caller process will have crashed. To prevent crash issues, this patch adds the exception handling to check whether the variable is nullptr or not. Change-Id: I8d81844466aa5056f08528afe23ec25810dfd6d2 Signed-off-by: Hwankyu Jhun --- diff --git a/src/modules/share/src/amd_share.c b/src/modules/share/src/amd_share.c index 02c232c2..a040c22e 100644 --- a/src/modules/share/src/amd_share.c +++ b/src/modules/share/src/amd_share.c @@ -759,14 +759,30 @@ static int __dispatch_unset_private_sharing(amd_request_h req) uid_t target_uid = amd_request_get_target_uid(req); bundle *data = amd_request_get_bundle(req); - caller_app_status = amd_app_status_find_by_pid(caller_pid); - caller_appid = amd_app_status_get_appid(caller_app_status); callee_appid = bundle_get_val(data, AUL_K_CALLEE_APPID); - callee_app_status = amd_app_status_find_by_appid(callee_appid, target_uid); - callee_pid = amd_app_status_get_pid(callee_app_status); + if (!callee_appid) { + _E("Failed to get callee appid"); + return -1; + } + + callee_app_status = amd_app_status_find_by_appid(callee_appid, + target_uid); + if (!callee_app_status) { + _E("Failed to find app status. appid(%s), uid(%u)", + callee_appid, target_uid); + return -1; + } - __temporary_permission_drop_with_owner(caller_appid, callee_pid, target_uid); + caller_app_status = amd_app_status_find_by_pid(caller_pid); + if (!caller_app_status) { + _E("Failed to find app status. pid(%d)", caller_pid); + return -1; + } + caller_appid = amd_app_status_get_appid(caller_app_status); + callee_pid = amd_app_status_get_pid(callee_app_status); + __temporary_permission_drop_with_owner(caller_appid, callee_pid, + target_uid); return 0; }