mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N
Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the appropriate cases. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
3217d445b9
commit
ee88bce43d
@ -67,6 +67,7 @@
|
|||||||
#include "backup_conf.h"
|
#include "backup_conf.h"
|
||||||
#include "virutil.h"
|
#include "virutil.h"
|
||||||
#include "virqemu.h"
|
#include "virqemu.h"
|
||||||
|
#include "virsecureerase.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -443,7 +444,8 @@ qemuDomainMasterKeyFree(qemuDomainObjPrivatePtr priv)
|
|||||||
if (!priv->masterKey)
|
if (!priv->masterKey)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen);
|
virSecureErase(priv->masterKey, priv->masterKeyLen);
|
||||||
|
g_clear_pointer(&priv->masterKey, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* qemuDomainMasterKeyReadFile:
|
/* qemuDomainMasterKeyReadFile:
|
||||||
@ -584,7 +586,8 @@ static void
|
|||||||
qemuDomainSecretPlainClear(qemuDomainSecretPlainPtr secret)
|
qemuDomainSecretPlainClear(qemuDomainSecretPlainPtr secret)
|
||||||
{
|
{
|
||||||
VIR_FREE(secret->username);
|
VIR_FREE(secret->username);
|
||||||
VIR_DISPOSE_N(secret->secret, secret->secretlen);
|
virSecureErase(secret->secret, secret->secretlen);
|
||||||
|
g_clear_pointer(&secret->secret, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1131,7 +1134,7 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPrivatePtr priv,
|
|||||||
g_autoptr(virConnect) conn = virGetConnectSecret();
|
g_autoptr(virConnect) conn = virGetConnectSecret();
|
||||||
qemuDomainSecretInfoPtr secinfo;
|
qemuDomainSecretInfoPtr secinfo;
|
||||||
g_autofree char *alias = qemuAliasForSecret(srcalias, secretuse);
|
g_autofree char *alias = qemuAliasForSecret(srcalias, secretuse);
|
||||||
uint8_t *secret = NULL;
|
g_autofree uint8_t *secret = NULL;
|
||||||
size_t secretlen = 0;
|
size_t secretlen = 0;
|
||||||
|
|
||||||
if (!conn)
|
if (!conn)
|
||||||
@ -1143,7 +1146,7 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPrivatePtr priv,
|
|||||||
|
|
||||||
secinfo = qemuDomainSecretAESSetup(priv, alias, username, secret, secretlen);
|
secinfo = qemuDomainSecretAESSetup(priv, alias, username, secret, secretlen);
|
||||||
|
|
||||||
VIR_DISPOSE_N(secret, secretlen);
|
virSecureErase(secret, secretlen);
|
||||||
|
|
||||||
return secinfo;
|
return secinfo;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user