]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Avoid corner case where esxUtil_ParseDatastorePath could be called with NULL...
authorPeter Krempa <pkrempa@redhat.com>
Mon, 2 Jun 2025 08:26:38 +0000 (10:26 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2025 11:11:03 +0000 (13:11 +0200)
The generated code which parses the data from XML in
esxVI_LookupDatastoreContentByDatastoreName can fill the 'folderPath'
property with NULL if it were missing from the input XML. While this is
not likely when talking to esx it is a possible outcome. Skipp NULL
results.

All other code paths already ensure that the function is not called with
NULL.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/776
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/esx/esx_storage_backend_vmfs.c

index 145aff0c9cb52587ffc620edcafa7d4954f68968..8e13201fe24c710562834898a9a70b0d49dbcc58 100644 (file)
@@ -616,6 +616,9 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
          searchResults = searchResults->_next) {
         g_autofree char *directoryAndFileName = NULL;
 
+        if (!searchResults->folderPath)
+            continue;
+
         if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NULL,
                                        &directoryAndFileName) < 0) {
             goto cleanup;
@@ -759,6 +762,9 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
              searchResults = searchResults->_next) {
             g_autofree char *directoryAndFileName = NULL;
 
+            if (searchResults->folderPath)
+                continue;
+
             if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL,
                                            NULL, &directoryAndFileName) < 0) {
                 goto cleanup;