]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N
authorPeter Krempa <pkrempa@redhat.com>
Mon, 1 Feb 2021 13:09:01 +0000 (14:09 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Feb 2021 12:07:12 +0000 (13:07 +0100)
Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tools/virsh-secret.c

index e413af893fcc4e731b2ada04e53ddd086427ebcc..de32f25d6406fdeaa363bd731f8e6dfb5c00535c 100644 (file)
@@ -303,7 +303,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
 {
     g_autoptr(virshSecret) secret = NULL;
     VIR_AUTODISPOSE_STR base64 = NULL;
-    unsigned char *value;
+    g_autofree unsigned char *value = NULL;
     size_t value_size;
     bool plain = vshCommandOptBool(cmd, "plain");
 
@@ -315,7 +315,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
 
     if (plain) {
         if (fwrite(value, 1, value_size, stdout) != value_size) {
-            VIR_DISPOSE_N(value, value_size);
+            virSecureErase(value, value_size);
             vshError(ctl, "failed to write secret");
             return false;
         }
@@ -325,7 +325,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
         vshPrint(ctl, "%s", base64);
     }
 
-    VIR_DISPOSE_N(value, value_size);
+    virSecureErase(value, value_size);
     return true;
 }