提交 c6adccae 编写于 作者: J John Ferlan 提交者: Cédric Bosdonnat

domain_conf: Check errors from virSocketAddrFormat

Commit id 'aa2cc721' added calls to virSocketAddrFormat but did not
check for a NULL (error) return which could lead to bad output
in the XML file.  Need to check for NULL return and cause failure.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 57e681e5
......@@ -17196,7 +17196,7 @@ virDomainFSDefFormat(virBufferPtr buf,
return 0;
}
static void
static int
virDomainNetIpsFormat(virBufferPtr buf, virDomainNetIpDefPtr *ips, size_t nips)
{
size_t i;
......@@ -17206,6 +17206,9 @@ virDomainNetIpsFormat(virBufferPtr buf, virDomainNetIpDefPtr *ips, size_t nips)
virSocketAddrPtr address = &ips[i]->address;
char *ipStr = virSocketAddrFormat(address);
const char *familyStr = NULL;
if (!ipStr)
return -1;
if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET6))
familyStr = "ipv6";
else if (VIR_SOCKET_ADDR_IS_FAMILY(address, AF_INET))
......@@ -17219,6 +17222,7 @@ virDomainNetIpsFormat(virBufferPtr buf, virDomainNetIpDefPtr *ips, size_t nips)
virBufferAsprintf(buf, " prefix='%u'", ips[i]->prefix);
virBufferAddLit(buf, "/>\n");
}
return 0;
}
static int
......@@ -17387,8 +17391,9 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
virBufferAddLit(buf, "</source>\n");
if (def->source.caps.type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
virDomainNetIpsFormat(buf, def->source.caps.u.net.ips,
def->source.caps.u.net.nips);
if (virDomainNetIpsFormat(buf, def->source.caps.u.net.ips,
def->source.caps.u.net.nips) < 0)
return -1;
if (virDomainNetRoutesFormat(buf, def->source.caps.u.net.routes,
def->source.caps.u.net.nroutes) < 0)
return -1;
......@@ -17780,7 +17785,8 @@ virDomainNetDefFormat(virBufferPtr buf,
return -1;
}
virDomainNetIpsFormat(buf, def->ips, def->nips);
if (virDomainNetIpsFormat(buf, def->ips, def->nips) < 0)
return -1;
if (virDomainNetRoutesFormat(buf, def->routes, def->nroutes) < 0)
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册