Blob Blame History Raw
From 9fccff47a561ba773a94dbf18e266771d674ca47 Mon Sep 17 00:00:00 2001
Message-Id: <9fccff47a561ba773a94dbf18e266771d674ca47@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 15 Aug 2016 10:12:15 -0400
Subject: [PATCH] virsh: Fix core for cmdSecretGetValue

https://bugzilla.redhat.com/show_bug.cgi?id=1366611

When commit id 'cb2e3e50' reworked the cmdSecretGetValue call to use
VIR_DISPOSE_STRING for base64, it neglected to initialize the base64
value to NULL since the cleanup: label could be reached prior to the
base64 value being set or not.  This resulted in a core dump, adding
the initialization will avoid the issue.

(cherry picked from commit 18701e9d6213be5a622d7c797f3a899b689e26b2)
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 tools/virsh-secret.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 8588f4c..537bdd7 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -253,7 +253,7 @@ static bool
 cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
 {
     virSecretPtr secret;
-    char *base64;
+    char *base64 = NULL;
     unsigned char *value;
     size_t value_size;
     bool ret = false;
-- 
2.9.2