]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/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)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Apr 2015 12:18:52 +0000 (14:18 +0200)
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.

src/util/virstoragefile.c

index 824cf5dcab28be74132f5e53cf287b8310bf0c9a..46aff923047c0fbb564dbb2b82a3644e0e90bdb9 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;