]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: storagefile: Don't pursue backing chain of NULL image
authorPeter Krempa <pkrempa@redhat.com>
Fri, 7 Mar 2014 10:38:18 +0000 (11:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 31 Mar 2014 11:47:50 +0000 (13:47 +0200)
When virStorageFileGetMetadata is called with NULL path argument, the
invalid pointer boils down through the recursive worker and is caught by
virHashAddEntry which is thankfully resistant to NULL arguments. As it
doesn't make sense to pursue backing chains of NULL volumes, exit
earlier.

This was noticed in the virt-aahelper-test with a slightly modified
codebase.

src/util/virstoragefile.c

index c7384d1dc4d64891fefafbff2eec5423a4fd571d..8370d235509340447d46b7eab65586562f323be4 100644 (file)
@@ -1118,7 +1118,7 @@ virStorageFileGetMetadata(const char *path, int format,
     virHashTablePtr cycle = virHashCreate(5, NULL);
     virStorageFileMetadataPtr ret;
 
-    if (!cycle)
+    if (!cycle || !path)
         return NULL;
 
     if (format <= VIR_STORAGE_FILE_NONE)