d89b3e
From 84fd99c804b4835bc459c0dd6195c9ab4b8129f4 Mon Sep 17 00:00:00 2001
d89b3e
Message-Id: <84fd99c804b4835bc459c0dd6195c9ab4b8129f4@dist-git>
d89b3e
From: Peter Krempa <pkrempa@redhat.com>
d89b3e
Date: Wed, 4 Mar 2015 18:13:42 +0100
d89b3e
Subject: [PATCH] util: storagefile: Don't crash on gluster URIs without path
d89b3e
d89b3e
https://bugzilla.redhat.com/show_bug.cgi?id=1198720
d89b3e
d89b3e
Similar to commit fdb80ed4f6563928b9942a0d1450e0c725aa6c06 libvirtd
d89b3e
would crash if a gluster URI without path would be used in the backing
d89b3e
chain of a volume. The crash happens in the gluster specific part of the
d89b3e
parser that extracts the gluster volume name from the path.
d89b3e
d89b3e
Fix the crash by checking that the PATH is NULL.
d89b3e
d89b3e
This patch does not contain a test case as it's not possible to test it
d89b3e
with the current infrastructure as the test suite would attempt to
d89b3e
contact the gluster server in the URI. I'm working on the test suite
d89b3e
addition but that will be post-release material.
d89b3e
d89b3e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1196528
d89b3e
(cherry picked from commit fc56ecd73520d3a3680d6f7500944298a99f254d)
d89b3e
d89b3e
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
d89b3e
---
d89b3e
 src/util/virstoragefile.c | 7 +++++++
d89b3e
 1 file changed, 7 insertions(+)
d89b3e
d89b3e
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
d89b3e
index 3ab20a4..8fa1e69 100644
d89b3e
--- a/src/util/virstoragefile.c
d89b3e
+++ b/src/util/virstoragefile.c
d89b3e
@@ -2157,6 +2157,13 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
d89b3e
 
d89b3e
     if (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) {
d89b3e
         char *tmp;
d89b3e
+
d89b3e
+        if (!src->path) {
d89b3e
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d89b3e
+                           _("missing volume name and path for gluster volume"));
d89b3e
+            goto cleanup;
d89b3e
+        }
d89b3e
+
d89b3e
         if (!(tmp = strchr(src->path, '/')) ||
d89b3e
             tmp == src->path) {
d89b3e
             virReportError(VIR_ERR_XML_ERROR,
d89b3e
-- 
d89b3e
2.3.3
d89b3e