mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
virDomainChrSourceReconnectDefParseXML: Use virXMLProp*
This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `timeout`. Allowing negative numbers to be interpreted this way makes no sense for this attribute. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
1b1cb2934e
commit
38d76cde5e
@ -10093,39 +10093,20 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDef *def,
|
||||
xmlNodePtr node,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
int tmpVal;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
xmlNodePtr cur;
|
||||
g_autofree char *tmp = NULL;
|
||||
|
||||
ctxt->node = node;
|
||||
|
||||
if ((cur = virXPathNode("./reconnect", ctxt))) {
|
||||
if ((tmp = virXMLPropString(cur, "enabled"))) {
|
||||
if ((tmpVal = virTristateBoolTypeFromString(tmp)) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid reconnect enabled value: '%s'"),
|
||||
tmp);
|
||||
return -1;
|
||||
}
|
||||
def->enabled = tmpVal;
|
||||
VIR_FREE(tmp);
|
||||
}
|
||||
if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE,
|
||||
&def->enabled) < 0)
|
||||
return -1;
|
||||
|
||||
if (def->enabled == VIR_TRISTATE_BOOL_YES) {
|
||||
if ((tmp = virXMLPropString(cur, "timeout"))) {
|
||||
if (virStrToLong_ui(tmp, NULL, 10, &def->timeout) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("invalid reconnect timeout value: '%s'"),
|
||||
tmp);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("missing timeout for chardev with "
|
||||
"reconnect enabled"));
|
||||
if (virXMLPropUInt(cur, "timeout", 10, VIR_XML_PROP_REQUIRED,
|
||||
&def->timeout) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user