[PATCH 06/14] qemu: domain: Use memset for clearing secrets instead of VIR_DISPOSE_N

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

 



Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the
appropriate cases.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2c34307c82..7f3f704bf4 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -443,7 +443,10 @@ qemuDomainMasterKeyFree(qemuDomainObjPrivatePtr priv)
     if (!priv->masterKey)
         return;

-    VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen);
+    if (priv->masterKey) {
+        memset(priv->masterKey, 0, priv->masterKeyLen);
+        g_clear_pointer(&priv->masterKey, g_free);
+    }
 }

 /* qemuDomainMasterKeyReadFile:
@@ -584,7 +587,10 @@ static void
 qemuDomainSecretPlainClear(qemuDomainSecretPlainPtr secret)
 {
     VIR_FREE(secret->username);
-    VIR_DISPOSE_N(secret->secret, secret->secretlen);
+    if (secret->secret) {
+        memset(secret->secret, 0, secret->secretlen);
+        g_clear_pointer(&secret->secret, g_free);
+    }
 }


@@ -1143,7 +1149,8 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPrivatePtr priv,

     secinfo = qemuDomainSecretAESSetup(priv, alias, username, secret, secretlen);

-    VIR_DISPOSE_N(secret, secretlen);
+    memset(secret, 0, secretlen);
+    g_free(secret);

     return secinfo;
 }
-- 
2.29.2




[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