mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N
Clear the secret right after use with virSecureErase. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
fabd172065
commit
3217d445b9
@ -46,6 +46,7 @@
|
|||||||
#include "xen_xl.h"
|
#include "xen_xl.h"
|
||||||
#include "virnetdevvportprofile.h"
|
#include "virnetdevvportprofile.h"
|
||||||
#include "virenum.h"
|
#include "virenum.h"
|
||||||
|
#include "virsecureerase.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||||
|
|
||||||
@ -998,14 +999,15 @@ static int
|
|||||||
libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
|
libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
|
||||||
{
|
{
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
uint8_t *secret = NULL;
|
|
||||||
VIR_AUTODISPOSE_STR base64secret = NULL;
|
VIR_AUTODISPOSE_STR base64secret = NULL;
|
||||||
size_t secretlen = 0;
|
|
||||||
char *username = NULL;
|
char *username = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
*srcstr = NULL;
|
*srcstr = NULL;
|
||||||
if (src->auth && src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
|
if (src->auth && src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
|
||||||
|
g_autofree uint8_t *secret = NULL;
|
||||||
|
size_t secretlen = 0;
|
||||||
|
|
||||||
username = src->auth->username;
|
username = src->auth->username;
|
||||||
if (!(conn = virConnectOpen("xen:///system")))
|
if (!(conn = virConnectOpen("xen:///system")))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1017,6 +1019,7 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
|
|||||||
|
|
||||||
/* RBD expects an encoded secret */
|
/* RBD expects an encoded secret */
|
||||||
base64secret = g_base64_encode(secret, secretlen);
|
base64secret = g_base64_encode(secret, secretlen);
|
||||||
|
virSecureErase(secret, secretlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*srcstr = libxlMakeNetworkDiskSrcStr(src, username, base64secret)))
|
if (!(*srcstr = libxlMakeNetworkDiskSrcStr(src, username, base64secret)))
|
||||||
@ -1025,7 +1028,6 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_DISPOSE_N(secret, secretlen);
|
|
||||||
virObjectUnref(conn);
|
virObjectUnref(conn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user