
Heidi Eckhart wrote:
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1201258415 -3600 # Node ID a6f0628644c1a666eea8be9993ad84ca688d65f4 # Parent adf18661f7948a0287a4586d97572793e8e03826 HostSystem: check if input ref is valid Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com>
diff -r adf18661f794 -r a6f0628644c1 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Thu Jan 24 12:56:45 2008 +0100 +++ b/src/Virt_HostSystem.c Fri Jan 25 11:53:35 2008 +0100 @@ -112,19 +112,35 @@ CMPIStatus get_host_cs(const CMPIBroker
static CMPIStatus return_host_cs(const CMPIObjectPath *reference, const CMPIResult *results, - int name_only) + bool name_only, + bool getInstance) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance;
s = get_host_cs(_BROKER, reference, &instance); - if (s.rc != CMPI_RC_OK || instance == NULL) - goto out; + if (s.rc != CMPI_RC_OK) + goto out; + + if (instance == NULL) { + if (getInstance) + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + if (getInstance) { + s = cu_validate_ref(_BROKER, reference, instance); + if (s.rc != CMPI_RC_OK) + goto out; + }
if (name_only) cu_return_instance_name(results, instance); else CMReturnInstance(results, instance); + out: return s; } @@ -164,7 +180,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_host_cs(reference, results, 1); + return return_host_cs(reference, results, 1, false);
I totally forgot this when I brought up the function declaration, but the calls (this one and I think two more here; not sure about other files) should probably be changed as well. Using 0 and 1 will work exactly the same, since that's literally what true and false get defined to by stdbool, but for readability 0 and 1 should be replaced with false and true, respectively. Sorry for not catching that earlier. -- -Jay