From: Youngjae Cho Date: Thu, 7 Sep 2023 12:44:00 +0000 (+0900) Subject: resource-manager: Validate attribute before update it X-Git-Tag: accepted/tizen/unified/20230913.091610^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69d24886f3cb4e904ba93618f260807013f8f677;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git resource-manager: Validate attribute before update it Add check_attr_validate() for all NORMAL type getter, making it affect the update_resource_attr(). Change-Id: Ic2be4c565226fa4f9a4be14118a44bd9aa5a9468 Signed-off-by: Youngjae Cho --- diff --git a/src/resource-manager/resource-manager.c b/src/resource-manager/resource-manager.c index 8af6bf3..72171d8 100644 --- a/src/resource-manager/resource-manager.c +++ b/src/resource-manager/resource-manager.c @@ -1140,6 +1140,9 @@ syscommon_resman_get_resource_attr_int(int resource_id, u_int64_t attr_id, int32 if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_INT)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1156,6 +1159,9 @@ syscommon_resman_get_resource_attr_int64(int resource_id, u_int64_t attr_id, int if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_INT64)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1172,6 +1178,9 @@ syscommon_resman_get_resource_attr_uint(int resource_id, u_int64_t attr_id, u_in if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1188,6 +1197,9 @@ syscommon_resman_get_resource_attr_uint64(int resource_id, u_int64_t attr_id, u_ if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1204,6 +1216,9 @@ syscommon_resman_get_resource_attr_uint64_with_1_user_data(int resource_id, u_in if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_1_USER_DATA)) + return -EINVAL; + ret = update_resource_attr_with_1_user_data(resource, attr_id, user_data1, 1); if (ret < 0) return ret; @@ -1220,6 +1235,9 @@ syscommon_resman_get_resource_attr_uint64_with_2_user_data(int resource_id, u_in if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA)) + return -EINVAL; + ret = update_resource_attr_with_2_user_data(resource, attr_id, user_data1, user_data2, 1, 1); if (ret < 0) return ret; @@ -1236,6 +1254,9 @@ syscommon_resman_get_resource_attr_double(int resource_id, u_int64_t attr_id, do if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1252,6 +1273,9 @@ syscommon_resman_get_resource_attr_string(int resource_id, u_int64_t attr_id, ch if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_STRING)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1268,6 +1292,9 @@ syscommon_resman_get_resource_attr_array(int resource_id, u_int64_t attr_id, str if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_ARRAY)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret; @@ -1284,6 +1311,9 @@ syscommon_resman_get_resource_attr_ptr(int resource_id, u_int64_t attr_id, void if (!is_valid_resource(resource, INSTANCE_TYPE_NORMAL)) return -EINVAL; + if (!check_attr_validate(resource, attr_id, SYSCOMMON_RESMAN_DATA_TYPE_PTR)) + return -EINVAL; + ret = update_resource_attr(resource, attr_id); if (ret < 0) return ret;