[PATCH 04/14] libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N

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

 



Clear the secret right after use with memset.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libxl/libxl_conf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index cb1fd7df7d..b2fcb21324 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -998,14 +998,15 @@ static int
 libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
 {
     virConnectPtr conn = NULL;
-    uint8_t *secret = NULL;
     VIR_AUTODISPOSE_STR base64secret = NULL;
-    size_t secretlen = 0;
     char *username = NULL;
     int ret = -1;

     *srcstr = NULL;
     if (src->auth && src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
+        g_autofree uint8_t *secret = NULL;
+        size_t secretlen = 0;
+
         username = src->auth->username;
         if (!(conn = virConnectOpen("xen:///system")))
             goto cleanup;
@@ -1017,6 +1018,7 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)

         /* RBD expects an encoded secret */
         base64secret = g_base64_encode(secret, secretlen);
+        memset(secret, 0, secretlen);
     }

     if (!(*srcstr = libxlMakeNetworkDiskSrcStr(src, username, base64secret)))
@@ -1025,7 +1027,6 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
     ret = 0;

  cleanup:
-    VIR_DISPOSE_N(secret, secretlen);
     virObjectUnref(conn);
     return ret;
 }
-- 
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