]> xenbits.xensource.com Git - libvirt.git/commit
snapshot: conf: Fix NULL dereference when <driver> element is empty
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Nov 2013 10:56:47 +0000 (11:56 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 2 Dec 2013 13:31:02 +0000 (14:31 +0100)
commit5a66c667ff5cae61c2ad2e646c8eb3eedc67f925
treeec4b962beb531bcae0f10da19031fede1e81f36e
parent43f2ccdc73090bd03f64de4d58d46ffa0134d705
snapshot: conf: Fix NULL dereference when <driver> element is empty

Consider the following valid snapshot XML as the <driver> element is
allowed to be empty in the domainsnapshot.rng schema:

$ cat snap.xml
<domainsnapshot>
  <disks>
    <disk name='vda' snapshot='external'>
      <source file='/tmp/foo'/>
      <driver/>
    </disk>
  </disks>
</domainsnapshot>

produces the following error:

$ virsh snapshot-create domain snap.xml
error: internal error: unknown disk snapshot driver '(null)'

The driver type is parsed as NULL from the XML as the attribute is not
present and then directly used to produce the error message.

With this patch the attempt to parse the driver type is skipped if not
present to avoid changing the schema to forbid the empty driver element.
src/conf/snapshot_conf.c