[PATCH] libvirt: ensure defresult is used in virConnectAuthCallbackDefault

Matt Coleman mcoleman at datto.com
Tue Sep 22 02:01:46 UTC 2020


A previous change to this function's password handling broke the use of
default values for credential types other than VIR_CRED_PASSPHRASE and
VIR_CRED_NOECHOPROMPT.

Signed-off-by: Matt Coleman <matt at datto.com>
---
 src/libvirt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 0748eb2352..63c8bdea9f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -146,7 +146,9 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred,
             len = strlen(buf);
             if (len != 0 && buf[len-1] == '\n')
                 buf[len-1] = '\0';
-            bufptr = g_strdup(buf);
+
+            if (strlen(buf) > 0)
+                bufptr = g_strdup(buf);
             break;
 
         case VIR_CRED_PASSPHRASE:
-- 
2.27.0





More information about the libvir-list mailing list