Return NULL when the given privilege doesn't have DID to display 41/231441/1 accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20200423.150458 accepted/tizen/5.5/unified/wearable/hotfix/20201027.112419 submit/tizen_5.5/20200422.050543 submit/tizen_5.5_wearable_hotfix/20201026.184304
authorYunjin Lee <yunjin-.lee@samsung.com>
Wed, 22 Apr 2020 04:12:27 +0000 (13:12 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Wed, 22 Apr 2020 04:12:27 +0000 (13:12 +0900)
- 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 <yunjin-.lee@samsung.com>
packaging/privilege-info.spec
src/privilege_information.c

index eefdaa9..5429de2 100644 (file)
@@ -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
index 995c29c..d8e001c 100755 (executable)
@@ -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.");