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