From ce5ced1d00d64e23c27f21e543feb8b8fe697306 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 3 Mar 2010 18:47:12 +0000 Subject: [PATCH] Fix parser checking of storage pool device The storage backend implementations all presume that the XML parser is validating correctness of the source specification. The check for a source device was lost at some point. This allowed for a potential crash in the disk backend. Re-introduce the sanity check * src/conf/storage_conf.c: Re-add check for source device --- src/conf/storage_conf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 19a1db9d71..b0f326fc39 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -689,6 +689,15 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { } } + /* If DEVICE is the only source type, then its required */ + if (options->flags == VIR_STORAGE_POOL_SOURCE_DEVICE) { + if (!ret->source.ndevice) { + virStorageReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool source device name")); + goto cleanup; + } + } + if ((ret->target.path = virXPathString("string(./target/path)", ctxt)) == NULL) { virStorageReportError(VIR_ERR_XML_ERROR, "%s", _("missing storage pool target path")); -- GitLab