提交 770b1d2b 编写于 作者: J Jiri Denemark

conf: Make virNetworkIPDefParseXML a little bit saner

Iterating over all child nodes when we only support one instance of each
child is pretty weird. And it would even cause memory leaks if more
than one <tftp> element was specified.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 9e930554
......@@ -1501,7 +1501,8 @@ virNetworkIPDefParseXML(const char *networkName,
* On failure clear it out, but don't free it.
*/
xmlNodePtr cur, save;
xmlNodePtr save;
xmlNodePtr dhcp;
char *address = NULL, *netmask = NULL;
unsigned long prefix = 0;
int prefixRc;
......@@ -1603,29 +1604,20 @@ virNetworkIPDefParseXML(const char *networkName,
goto cleanup;
}
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "dhcp")) {
if (virNetworkDHCPDefParseXML(networkName, cur, def) < 0)
goto cleanup;
} else if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "tftp")) {
char *root;
if ((dhcp = virXPathNode("./dhcp[1]", ctxt)) &&
virNetworkDHCPDefParseXML(networkName, dhcp, def) < 0)
goto cleanup;
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported <tftp> element in an IPv6 element in network '%s'"),
networkName);
goto cleanup;
}
if (!(root = virXMLPropString(cur, "root"))) {
cur = cur->next;
continue;
}
def->tftproot = (char *)root;
if (virXPathNode("./tftp[1]", ctxt)) {
if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported <tftp> element in an IPv6 element "
"in network '%s'"),
networkName);
goto cleanup;
}
cur = cur->next;
def->tftproot = virXPathString("string(./tftp[1]/@root)", ctxt);
}
result = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册