]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt: Fix crash on URI without scheme
authorCole Robinson <crobinso@redhat.com>
Wed, 20 Apr 2016 17:25:07 +0000 (13:25 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Apr 2016 13:29:20 +0000 (09:29 -0400)
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

index 749089bdc7a46488d76d3f1915256fe1140c8842..114e88ca8f9c236031f7b2d656b932c498da6f89 100644 (file)
@@ -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,