From patchwork Wed Apr 20 17:31:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66226 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2580955qge; Wed, 20 Apr 2016 10:34:02 -0700 (PDT) X-Received: by 10.55.24.215 with SMTP id 84mr13338961qky.53.1461173642421; Wed, 20 Apr 2016 10:34:02 -0700 (PDT) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id m144si9139745qhb.42.2016.04.20.10.34.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Apr 2016 10:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3KHVHUb010563; Wed, 20 Apr 2016 13:31:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3KHVGuQ020698 for ; Wed, 20 Apr 2016 13:31:16 -0400 Received: from colepc.redhat.com (ovpn-113-99.phx2.redhat.com [10.3.113.99]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3KHVFqk012774; Wed, 20 Apr 2016 13:31:16 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 20 Apr 2016 13:31:07 -0400 Message-Id: <6557ce205f154c6a7ae064e752de33b6d89770f1.1461173467.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] libvirt: Fix crash on URI without scheme X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com 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 --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,