From: Yunjin Lee Date: Wed, 22 Apr 2020 04:12:27 +0000 (+0900) Subject: Return NULL when the given privilege doesn't have DID to display X-Git-Tag: submit/tizen_5.5/20200422.050543^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8096cd043bc0e08a9290feee104f33cfe89f3254;p=platform%2Fcore%2Fsecurity%2Fprivilege-info.git Return NULL when the given privilege doesn't have DID to display - Return NULL if there's no DID for the given privilege in privilege DB - Skip 0.0.4 to avoid version conflict between the tizen branch and current branch. This branch will continue 0.0.x versioning and tizen branch will use 0.1.x versioning for the next time. Change-Id: Iafa9bbe948efd3e68d9736bd37e24d789668c4cb Signed-off-by: Yunjin Lee --- diff --git a/packaging/privilege-info.spec b/packaging/privilege-info.spec index eefdaa9..5429de2 100644 --- a/packaging/privilege-info.spec +++ b/packaging/privilege-info.spec @@ -1,6 +1,6 @@ Name: privilege-info Summary: Privilege Information -Version: 0.0.3 +Version: 0.0.5 Release: 1 Group: Security/API License: Apache-2.0 diff --git a/src/privilege_information.c b/src/privilege_information.c index 995c29c..d8e001c 100755 --- a/src/privilege_information.c +++ b/src/privilege_information.c @@ -116,8 +116,12 @@ get_string_id_with_package_type: goto err_internal_error; err_none: - *string_id = strdup(temp); - TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); + if (strlen(temp) == 0) { + *string_id = NULL; + } else { + *string_id = strdup(temp); + TryReturn(*string_id != NULL, free(temp), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation is failed."); + } free(temp); return PRVINFO_ERROR_NONE; @@ -173,6 +177,7 @@ int privilege_info_get_display_name(const char *api_version, const char *privile TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); free(tempPrivilege); } else if (ret == PRVINFO_ERROR_NONE) { + TryReturn(string_id != NULL, *display_name = NULL, PRVINFO_ERROR_NONE, "No DID for privilege : %s", privilege); ret = privilege_info_get_string_by_string_id(string_id, display_name); free(string_id); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); @@ -197,6 +202,7 @@ int privilege_info_get_description(const char *api_version, const char *privileg ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); } else if (ret == PRVINFO_ERROR_NONE) { + TryReturn(string_id != NULL, *description = NULL, PRVINFO_ERROR_NONE, "No DID for privilege : %s", privilege); ret = privilege_info_get_string_by_string_id(string_id, description); free(string_id); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); @@ -235,6 +241,7 @@ int privilege_info_get_display_name_by_pkgtype(const char *package_type, const c TryReturn(*display_name != NULL, free(tempPrivilege), PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); free(tempPrivilege); } else if (ret == PRVINFO_ERROR_NONE) { + TryReturn(string_id != NULL, *display_name = NULL, PRVINFO_ERROR_NONE, "No DID for privilege : %s", privilege); ret = privilege_info_get_string_by_string_id(string_id, display_name); free(string_id); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); @@ -261,6 +268,7 @@ int privilege_info_get_description_by_pkgtype(const char *package_type, const ch ret = privilege_info_get_string_by_string_id("IDS_TPLATFORM_BODY_THIS_PRIVILEGE_IS_NOT_DEFINED", description); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed."); } else if (ret == PRVINFO_ERROR_NONE) { + TryReturn(string_id != NULL, *description = NULL, PRVINFO_ERROR_NONE, "No DID for privilege : %s", privilege); ret = privilege_info_get_string_by_string_id(string_id, description); free(string_id); TryReturn(ret == PRVINFO_ERROR_NONE, , PRVINFO_ERROR_OUT_OF_MEMORY, "[PRVINFO_ERROR_OUT_OF_MEMORY] Memory allocation failed.");