[Libvirt-cim] [PATCH 2 of 5] HD: validate client given object path

Heidi Eckhart heidieck at linux.vnet.ibm.com
Fri Feb 29 12:30:34 UTC 2008


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1204286655 -3600
# Node ID 2c8c7521952cbd89db590822bca22775f07fc8e2
# Parent  b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670
HD: validate client given object path

wbemain -ac KVM_HostedDependency 'http://localhost/root/virt:KVM_HostSystem.CreationClassName="KVM_HostSystem",Name="wrong"'
returns instances instead of NOT_FOUND

wbemain -ac CIM_HostedDependency 'http://localhost/root/virt:KVM_ComputerSystem.CreationClassName="KVM_ComputerSystem",Name="wrong"'
returns an instance instead of NOT_FOUND

Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r b0bc7c2f51e4 -r 2c8c7521952c src/Virt_HostedDependency.c
--- a/src/Virt_HostedDependency.c	Fri Feb 29 13:04:13 2008 +0100
+++ b/src/Virt_HostedDependency.c	Fri Feb 29 13:04:15 2008 +0100
@@ -41,15 +41,20 @@ static CMPIStatus vs_to_host(const CMPIO
                              struct inst_list *list)
 {
         CMPIStatus s = {CMPI_RC_OK, NULL};
-        CMPIInstance *instance;
+        CMPIInstance *instance = NULL;
 
         if (!match_hypervisor_prefix(ref, info))
-                return s;
+                goto out;
 
-        s = get_host_cs(_BROKER, ref, &instance);
+        s = get_domain(_BROKER, ref, &instance);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
+        s = get_host(_BROKER, ref, &instance, false);
         if (s.rc == CMPI_RC_OK)
                 inst_list_add(list, instance);
 
+ out:
         return s;
 }
 
@@ -60,29 +65,29 @@ static CMPIStatus host_to_vs(const CMPIO
         int ret;
         virConnectPtr conn;
         CMPIStatus s = {CMPI_RC_OK, NULL};
+        CMPIInstance *instance = NULL;
 
         if (!match_hypervisor_prefix(ref, info))
-                return s;
+                goto out;
+
+        s = get_host(_BROKER, ref, &instance, true);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
 
         conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
         if (conn == NULL)
-                return s;
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "No such instance");
+                goto out;
 
         ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list);
-        if (ret) {
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_OK,
-                           "");
-        } else {
+        if (!ret)
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Failed to get domain list");
-        }
 
-        cu_statusf(_BROKER, &s,
-                   CMPI_RC_OK,
-                   "");
-
+ out:
         return s;
 }
 




More information about the Libvirt-cim mailing list