]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: Fix possible crash when source path is NULL
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Apr 2015 15:35:23 +0000 (17:35 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 28 Apr 2015 15:26:08 +0000 (11:26 -0400)
Some storage protocols allow to have the @path field in struct
virStorageSource set to NULL. Add NULLSTR() wrappers to handle this
possibility until I finish the storage source error formatter.

(cherry picked from commit 62a61d583c65fb5e4e56f49af33f926b6a0cba6e)

src/util/virstoragefile.c

index 78a7a9f8b935c5bfb77fcc8b6f3defb8e731fb51..2e0d97f08a22ea4c6c7d38ef3d44b52bb781e3bf 100644 (file)
@@ -1391,20 +1391,21 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
     if (idx) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("could not find backing store %u in chain for '%s'"),
-                       idx, start);
+                       idx, NULLSTR(start));
     } else if (name) {
         if (startFrom)
             virReportError(VIR_ERR_INVALID_ARG,
                            _("could not find image '%s' beneath '%s' in "
-                             "chain for '%s'"), name, startFrom->path, start);
+                             "chain for '%s'"), name, NULLSTR(startFrom->path),
+                           NULLSTR(start));
         else
             virReportError(VIR_ERR_INVALID_ARG,
                            _("could not find image '%s' in chain for '%s'"),
-                           name, start);
+                           name, NULLSTR(start));
     } else {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("could not find base image in chain for '%s'"),
-                       start);
+                       NULLSTR(start));
     }
     *parent = NULL;
     return NULL;