util: storage: Fix possible crash when source path is NULL

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.
This commit is contained in:
Peter Krempa 2015-04-21 17:35:23 +02:00
parent 64a9d2fa2f
commit 62a61d583c
1 changed files with 5 additions and 4 deletions

View 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;