# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1199880495 -3600
# Node ID ae476a5a5ab9891f4fbd3591e4175173f6b55c8b
# Parent a6edc1c843ecbc619dbd40da2f4cedc58e45ba27
RAFP: validation of client given object path is missing
The validation of the client's given object path for a
ResourceAllocationSettingData instance is missing. The
provider accepts InstanceIDs that do not exist, instead
of returning NOT_FOUND.
Example:
wbemcli ain -ac KVM_ResourceAllocationFromPool
http://localhost/root/virt:KVM_ProcResourceAllocationSettingData.Instance...
returns
localhost:5988/root/virt:KVM_ProcessorPool.InstanceID="ProcessorPool/0"
Also removed unused inst_list _list.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r a6edc1c843ec -r ae476a5a5ab9 src/Virt_ResourceAllocationFromPool.c
--- a/src/Virt_ResourceAllocationFromPool.c Tue Jan 08 13:23:53 2008 -0800
+++ b/src/Virt_ResourceAllocationFromPool.c Wed Jan 09 13:08:15 2008 +0100
@@ -37,6 +37,28 @@
const static CMPIBroker *_BROKER;
+static CMPIStatus validate_rasd_ref(const CMPIContext *context,
+ const CMPIObjectPath *ref,
+ uint16_t type,
+ const char *id)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *rasd = NULL;
+
+ rasd = get_rasd_instance(context,
+ ref,
+ _BROKER,
+ id,
+ type);
+
+ if (CMIsNullObject(rasd))
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)", id);
+
+ return s;
+}
+
static CMPIStatus rasd_to_pool(const CMPIObjectPath *ref,
struct std_assoc_info *info,
struct inst_list *list)
@@ -46,14 +68,11 @@ static CMPIStatus rasd_to_pool(const CMP
const char *id = NULL;
char *poolid = NULL;
virConnectPtr conn = NULL;
- struct inst_list _list;
CMPIInstance *pool = NULL;
if (!match_hypervisor_prefix(ref, info))
return s;
- inst_list_init(&_list);
-
if (rasd_type_from_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -67,6 +86,13 @@ static CMPIStatus rasd_to_pool(const CMP
"Missing InstanceID");
goto out;
}
+
+ s = validate_rasd_ref(info->context,
+ ref,
+ type,
+ id);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
poolid = pool_member_of(_BROKER, CLASSNAME(ref), type, id);
if (poolid == NULL) {
@@ -96,7 +122,6 @@ static CMPIStatus rasd_to_pool(const CMP
out:
free(poolid);
virConnectClose(conn);
- inst_list_free(&_list);
return s;
}