Fix crash issue 17/266917/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Nov 2021 09:23:07 +0000 (18:23 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Nov 2021 09:27:25 +0000 (18:27 +0900)
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 <h.jhun@samsung.com>
src/modules/share/src/amd_share.c

index 02c232c..a040c22 100644 (file)
@@ -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;
 }