[PATCH 2/2] remote: properly initialize objects in ACL helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 2ecdf259299813c2c674377e22a0acbce5ccbbb2 is idealogically corrent,
but unfortunately is incomplete. There are other similar objects in the
module which are used also without proper initialization.

This patch adds proper clauses to
    remoteRelayNetworkEventCheckACL
    remoteRelayStoragePoolEventCheckACL
    remoteRelayNodeDeviceEventCheckACL
    remoteRelaySecretEventCheckACL

Signed-off-by: Denis V. Lunev <den@xxxxxxxxxx>
CC: Peter Krempa <pkrempa@xxxxxxxxxx>
CC: Roman Grigoriev <rgrigoriev@xxxxxxxxxxxxx>
---
 src/remote/remote_daemon_dispatch.c | 32 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 3172a632df..01f97bb345 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -180,21 +180,21 @@ static bool
 remoteRelayNetworkEventCheckACL(virNetServerClient *client,
                                 virConnectPtr conn, virNetworkPtr net)
 {
-    virNetworkDef def;
+    g_autoptr(virNetworkDef) def = g_new0(virNetworkDef, 1);
     g_autoptr(virIdentity) identity = NULL;
     bool ret = false;
 
     /* For now, we just create a virNetworkDef with enough contents to
      * satisfy what viraccessdriverpolkit.c references.  This is a bit
      * fragile, but I don't know of anything better.  */
-    def.name = net->name;
-    memcpy(def.uuid, net->uuid, VIR_UUID_BUFLEN);
+    def->name = g_strdup(net->name);
+    memcpy(def->uuid, net->uuid, VIR_UUID_BUFLEN);
 
     if (!(identity = virNetServerClientGetIdentity(client)))
         goto cleanup;
     if (virIdentitySetCurrent(identity) < 0)
         goto cleanup;
-    ret = virConnectNetworkEventRegisterAnyCheckACL(conn, &def);
+    ret = virConnectNetworkEventRegisterAnyCheckACL(conn, def);
 
  cleanup:
     ignore_value(virIdentitySetCurrent(NULL));
@@ -206,21 +206,21 @@ remoteRelayStoragePoolEventCheckACL(virNetServerClient *client,
                                     virConnectPtr conn,
                                     virStoragePoolPtr pool)
 {
-    virStoragePoolDef def;
+    g_autoptr(virStoragePoolDef) def = g_new0(virStoragePoolDef, 1);
     g_autoptr(virIdentity) identity = NULL;
     bool ret = false;
 
     /* For now, we just create a virStoragePoolDef with enough contents to
      * satisfy what viraccessdriverpolkit.c references.  This is a bit
      * fragile, but I don't know of anything better.  */
-    def.name = pool->name;
-    memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN);
+    def->name = g_strdup(pool->name);
+    memcpy(def->uuid, pool->uuid, VIR_UUID_BUFLEN);
 
     if (!(identity = virNetServerClientGetIdentity(client)))
         goto cleanup;
     if (virIdentitySetCurrent(identity) < 0)
         goto cleanup;
-    ret = virConnectStoragePoolEventRegisterAnyCheckACL(conn, &def);
+    ret = virConnectStoragePoolEventRegisterAnyCheckACL(conn, def);
 
  cleanup:
     ignore_value(virIdentitySetCurrent(NULL));
@@ -232,20 +232,20 @@ remoteRelayNodeDeviceEventCheckACL(virNetServerClient *client,
                                    virConnectPtr conn,
                                    virNodeDevicePtr dev)
 {
-    virNodeDeviceDef def;
+    g_autoptr(virNodeDeviceDef) def = g_new0(virNodeDeviceDef, 1);
     g_autoptr(virIdentity) identity = NULL;
     bool ret = false;
 
     /* For now, we just create a virNodeDeviceDef with enough contents to
      * satisfy what viraccessdriverpolkit.c references.  This is a bit
      * fragile, but I don't know of anything better.  */
-    def.name = dev->name;
+    def->name = g_strdup(dev->name);
 
     if (!(identity = virNetServerClientGetIdentity(client)))
         goto cleanup;
     if (virIdentitySetCurrent(identity) < 0)
         goto cleanup;
-    ret = virConnectNodeDeviceEventRegisterAnyCheckACL(conn, &def);
+    ret = virConnectNodeDeviceEventRegisterAnyCheckACL(conn, def);
 
  cleanup:
     ignore_value(virIdentitySetCurrent(NULL));
@@ -257,22 +257,22 @@ remoteRelaySecretEventCheckACL(virNetServerClient *client,
                                virConnectPtr conn,
                                virSecretPtr secret)
 {
-    virSecretDef def;
+    g_autoptr(virSecretDef) def = g_new0(virSecretDef, 1);
     g_autoptr(virIdentity) identity = NULL;
     bool ret = false;
 
     /* For now, we just create a virSecretDef with enough contents to
      * satisfy what viraccessdriverpolkit.c references.  This is a bit
      * fragile, but I don't know of anything better.  */
-    memcpy(def.uuid, secret->uuid, VIR_UUID_BUFLEN);
-    def.usage_type = secret->usageType;
-    def.usage_id = secret->usageID;
+    memcpy(def->uuid, secret->uuid, VIR_UUID_BUFLEN);
+    def->usage_type = secret->usageType;
+    def->usage_id = secret->usageID;
 
     if (!(identity = virNetServerClientGetIdentity(client)))
         goto cleanup;
     if (virIdentitySetCurrent(identity) < 0)
         goto cleanup;
-    ret = virConnectSecretEventRegisterAnyCheckACL(conn, &def);
+    ret = virConnectSecretEventRegisterAnyCheckACL(conn, def);
 
  cleanup:
     ignore_value(virIdentitySetCurrent(NULL));
-- 
2.40.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux