]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix parser checking of storage pool device
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 3 Mar 2010 18:47:12 +0000 (18:47 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 4 Mar 2010 11:57:06 +0000 (11:57 +0000)
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

index 19a1db9d7104dd6a780a09ea52398da65b86485e..b0f326fc39ef6af8d89678dae35aa71d6722b89b 100644 (file)
@@ -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"));