[Libvirt-cim] [PATCH 2 of 5] GetInstance() in DevicePool returns an instance for invalid refs

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Jan 3 15:26:12 UTC 2008


Jay Gagnon wrote:
> Kaitlin Rupert wrote:
>> # HG changeset patch
>> # User Kaitlin Rupert <karupert at us.ibm.com>
>> # Date 1198261308 28800
>> # Node ID 40de750e13d37994bee0f7031e82f612d02ebe4d
>> # Parent  97c1cab36073319f7cf78cbec70eec9eaee01a4d
>> GetInstance() in DevicePool returns an instance for invalid refs.
>>
>> If a ref with a correct InstanceID but non-matching classname is passed, GetInstance() returns an instance that matches the InstanceID.  This should return an error.
>>
>> Add cu_compare_ref() after retrieving the instance to make sure ref is valid.
>>
>> Failing query:
>> wbemcli gi 'http://localhost:5988/root/virt:Xen_ProcessorPool.InstanceID="MemoryPool/0"'
>>
>> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>>
>>
>>          inst = get_pool_by_id(_BROKER, conn, id, NAMESPACE(reference));
>>          if (inst) {
>> +                prop = cu_compare_ref(reference, inst);
>> +                if (prop != NULL) {
>> +                        cu_statusf(broker, &s,
>> +                                   CMPI_RC_ERR_NOT_FOUND,
>> +                                   "No such ResourcePool instance (%s)", prop);
>> +                }
>>   
> Just want to make sure I understand something correctly.  You don't need
> to free prop here because cu_compare_ref gets it using CMGetCharPtr,
> right?  That memory is managed by the CIMOM for you?
> 
Yes, that's correct.  It's the same reason why you don't need to free an 
instance that's been created using CMNewInstance() (etc).

-- 
Kaitlin Rupert
IBM Linux Technology Center
karupert at us.ibm.com




More information about the Libvirt-cim mailing list