resource-manager: Validate attribute before update it 88/298588/1 accepted/tizen/8.0/unified/20231005.093814 accepted/tizen/unified/20230913.091610 tizen_8.0_m2_release
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 7 Sep 2023 12:44:00 +0000 (21:44 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 11 Sep 2023 06:15:12 +0000 (15:15 +0900)
Add check_attr_validate() for all NORMAL type getter, making it affect
the update_resource_attr().

Change-Id: Ic2be4c565226fa4f9a4be14118a44bd9aa5a9468
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/resource-manager/resource-manager.c

index 8af6bf3..72171d8 100644 (file)
@@ -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;