[libvirt] [PATCH 0/2] For 1.2.13 - Fix crash with gluster URIs

Peter Krempa (2): util: storagefile: Don't crash on gluster URIs without path util: storage: Fix error type in virStorageSourceParseBackingURI src/util/virstoragefile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.2.2

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 --- src/util/virstoragefile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 029fe17..ba00143 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2163,6 +2163,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.2.2

The gluster volume name extraction code was copied from the XML parser without changing the VIR_ERR_XML_ERROR error code. Use VIR_ERR_CONFIG_UNSUPPORTED instead. --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ba00143..78a7a9f 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2172,7 +2172,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src, if (!(tmp = strchr(src->path, '/')) || tmp == src->path) { - virReportError(VIR_ERR_XML_ERROR, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing volume name or file name in " "gluster source path '%s'"), src->path); goto cleanup; -- 2.2.2

On Thu, Feb 26, 2015 at 10:50:56AM +0100, Peter Krempa wrote:
Peter Krempa (2): util: storagefile: Don't crash on gluster URIs without path util: storage: Fix error type in virStorageSourceParseBackingURI
src/util/virstoragefile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
-- 2.2.2
ACK series and safe for freeze.
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Thu, Feb 26, 2015 at 11:35:08 +0100, Martin Kletzander wrote:
On Thu, Feb 26, 2015 at 10:50:56AM +0100, Peter Krempa wrote:
Peter Krempa (2): util: storagefile: Don't crash on gluster URIs without path util: storage: Fix error type in virStorageSourceParseBackingURI
src/util/virstoragefile.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
-- 2.2.2
ACK series and safe for freeze.
Thanks, pushed. Peter
participants (2)
-
Martin Kletzander
-
Peter Krempa