[PATCH 0 of 2] Update get_vsms() to validate references passed in.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1202919247 28800 # Node ID 88e4cf39a5b342606d6a126c429eb9f0f1c38ab8 # Parent be18b4c2084a6b2b1f1c3a1cdae25a98034d7d54 Update get_vsms() in VSMS to validate reference. Also change names_only from an int to a bool. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r be18b4c2084a -r 88e4cf39a5b3 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Feb 12 15:39:52 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Wed Feb 13 08:14:07 2008 -0800 @@ -1161,7 +1161,8 @@ STDIM_MethodMIStub(, Virt_VirtualSystemM CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker) + const CMPIBroker *broker, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; @@ -1171,8 +1172,14 @@ CMPIStatus get_vsms(const CMPIObjectPath *_inst = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + return s; + } inst = get_typed_instance(broker, pfx_from_conn(conn), @@ -1207,6 +1214,12 @@ CMPIStatus get_vsms(const CMPIObjectPath CMSetProperty(inst, "SystemCreationClassName", (CMPIValue *)ccname, CMPI_chars); + if (is_get_inst) { + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + } + CMSetStatus(&s, CMPI_RC_OK); out: @@ -1218,12 +1231,13 @@ CMPIStatus get_vsms(const CMPIObjectPath static CMPIStatus return_vsms(const CMPIObjectPath *reference, const CMPIResult *results, - int name_only) + bool name_only, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - s = get_vsms(reference, &inst, _BROKER); + s = get_vsms(reference, &inst, _BROKER, is_get_inst); if (s.rc != CMPI_RC_OK || inst == NULL) goto out; @@ -1240,7 +1254,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_vsms(reference, results, 1); + return return_vsms(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -1250,7 +1264,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_vsms(reference, results, 0); + return return_vsms(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -1259,25 +1273,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *ref, const char **properties) { - CMPIInstance *inst; - CMPIStatus s; - const char *prop; - - s = get_vsms(ref, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) - return s; - - prop = cu_compare_ref(ref, inst); - if (prop != NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", prop); - } else { - CMSetStatus(&s, CMPI_RC_OK); - CMReturnInstance(results, inst); - } - - return s; + return return_vsms(ref, results, false, true); } DEFAULT_CI(); diff -r be18b4c2084a -r 88e4cf39a5b3 src/Virt_VirtualSystemManagementService.h --- a/src/Virt_VirtualSystemManagementService.h Tue Feb 12 15:39:52 2008 -0800 +++ b/src/Virt_VirtualSystemManagementService.h Wed Feb 13 08:14:07 2008 -0800 @@ -21,4 +21,5 @@ CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, - const CMPIBroker *broker); + const CMPIBroker *broker, + bool is_get_inst);

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1202919397 28800 # Node ID 30beb44bdb1ffb789a031bd860e316f1e500abbb # Parent 88e4cf39a5b342606d6a126c429eb9f0f1c38ab8 Update calls to get_vsms() to include value for new is_get_inst param. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 88e4cf39a5b3 -r 30beb44bdb1f src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Wed Feb 13 08:14:07 2008 -0800 +++ b/src/Virt_ElementCapabilities.c Wed Feb 13 08:16:37 2008 -0800 @@ -64,7 +64,7 @@ static CMPIStatus validate_caps_get_serv if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; - s = get_vsms(ref, &_inst, _BROKER); + s = get_vsms(ref, &_inst, _BROKER, false); } else if (STREQC(classname, "VirtualSystemMigrationCapabilities")) { s = get_migration_caps(ref, &_inst, _BROKER); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) @@ -91,7 +91,7 @@ static CMPIStatus validate_service_get_c classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &_inst, _BROKER); + s = get_vsms(ref, &_inst, _BROKER, true); if ((s.rc != CMPI_RC_OK) || (_inst == NULL)) goto out; diff -r 88e4cf39a5b3 -r 30beb44bdb1f src/Virt_HostedService.c --- a/src/Virt_HostedService.c Wed Feb 13 08:14:07 2008 -0800 +++ b/src/Virt_HostedService.c Wed Feb 13 08:16:37 2008 -0800 @@ -47,7 +47,7 @@ static CMPIStatus validate_service_ref(c classname = class_base_name(CLASSNAME(ref)); if (STREQC(classname, "VirtualSystemManagementService")) { - s = get_vsms(ref, &inst, _BROKER); + s = get_vsms(ref, &inst, _BROKER, true); } else if (STREQC(classname, "ResourcePoolConfigurationService")) { s = get_rpcs(ref, &inst, _BROKER, true); } else if (STREQC(classname, "VirtualSystemMigrationService")) { @@ -111,7 +111,7 @@ static CMPIStatus host_to_service(const if (!CMIsNullObject(inst)) inst_list_add(list, inst); - s = get_vsms(ref, &inst, _BROKER); + s = get_vsms(ref, &inst, _BROKER, false); if (s.rc != CMPI_RC_OK) return s; if (!CMIsNullObject(inst))
participants (1)
-
Kaitlin Rupert