Do not crash on gluster snapshots with no host name

virStorageFileBackendGlusterInit did not check nhosts.

https://bugzilla.redhat.com/show_bug.cgi?id=1162974
This commit is contained in:
Ján Tomko 2014-11-12 09:34:28 +01:00
parent cce8e5f739
commit b66288faab

View File

@ -571,9 +571,17 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
{
virStorageFileBackendGlusterPrivPtr priv = NULL;
virStorageNetHostDefPtr host = &(src->hosts[0]);
const char *hostname = host->name;
const char *hostname;
int port = 0;
if (src->nhosts != 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expected exactly 1 host for the gluster volume"));
return -1;
}
hostname = host->name;
VIR_DEBUG("initializing gluster storage file %p (gluster://%s:%s/%s%s)",
src, hostname, host->port ? host->port : "0",
NULLSTR(src->volume), src->path);