diff mbox

libvirt: Fix crash on URI without scheme

Message ID 6557ce205f154c6a7ae064e752de33b6d89770f1.1461173467.git.crobinso@redhat.com
State Accepted
Commit f1bae376b71ecc712e5d8359382290db1120e13e
Headers show

Commit Message

Cole Robinson April 20, 2016, 5:31 p.m. UTC
My commit 0d1579572 crashes on a URI without a scheme, like via
'virsh --connect frob'

Add a check on uri->server too while we are at it, and centralize
them all
---
 src/libvirt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/libvirt.c b/src/libvirt.c
index 749089b..114e88c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -935,6 +935,9 @@  virConnectGetDefaultURI(virConfPtr conf,
 static int
 virConnectCheckURIMissingSlash(const char *uristr, virURIPtr uri)
 {
+    if (!uri->scheme || !uri->path || !uri->server)
+        return 0;
+
     /* To avoid false positives, only check drivers that mandate
        a path component in the URI, like /system or /session */
     if (STRNEQ(uri->scheme, "qemu") &&
@@ -942,9 +945,6 @@  virConnectCheckURIMissingSlash(const char *uristr, virURIPtr uri)
         STRNEQ(uri->scheme, "vz"))
         return 0;
 
-    if (uri->path != NULL)
-        return 0;
-
     if (STREQ(uri->server, "session") ||
         STREQ(uri->server, "system")) {
         virReportError(VIR_ERR_INTERNAL_ERROR,