mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Don't ignore errors parsing nwfilter rules
For inexplicable reasons, the nwfilter XML parser is intentionally
ignoring errors that arise during parsing. As well as meaning that
users don't get any feedback on their XML mistakes, this will lead
it to silently drop data in OOM conditions.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 4f2094346d
)
Conflicts:
tests/nwfilterxml2xmltest.c
- args to virNWFilterDefParseString are different, causing
small conflict in context.
This commit is contained in:
parent
49c6f2688b
commit
11a31c0880
@ -2379,9 +2379,7 @@ virNWFilterRuleParse(xmlNodePtr node)
|
||||
if (virNWFilterRuleDetailsParse(cur,
|
||||
ret,
|
||||
virAttr[i].att) < 0) {
|
||||
/* we ignore malformed rules
|
||||
goto err_exit;
|
||||
*/
|
||||
goto err_exit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2589,11 +2587,13 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* ignore malformed rule and include elements */
|
||||
if (xmlStrEqual(curr->name, BAD_CAST "rule"))
|
||||
entry->rule = virNWFilterRuleParse(curr);
|
||||
else if (xmlStrEqual(curr->name, BAD_CAST "filterref"))
|
||||
entry->include = virNWFilterIncludeParse(curr);
|
||||
if (xmlStrEqual(curr->name, BAD_CAST "rule")) {
|
||||
if (!(entry->rule = virNWFilterRuleParse(curr)))
|
||||
goto cleanup;
|
||||
} else if (xmlStrEqual(curr->name, BAD_CAST "filterref")) {
|
||||
if (!(entry->include = virNWFilterIncludeParse(curr)))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (entry->rule || entry->include) {
|
||||
if (VIR_REALLOC_N(ret->filterEntries, ret->nentries+1) < 0) {
|
||||
|
@ -33,15 +33,12 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (!(dev = virNWFilterDefParseString(inXmlData)))
|
||||
if (!(dev = virNWFilterDefParseString(inXmlData))) {
|
||||
if (expect_error) {
|
||||
virResetLastError();
|
||||
goto done;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
if (!!virGetLastError() != expect_error)
|
||||
goto fail;
|
||||
|
||||
if (expect_error) {
|
||||
/* need to suppress the errors */
|
||||
virResetLastError();
|
||||
}
|
||||
|
||||
if (!(actual = virNWFilterDefFormat(dev)))
|
||||
@ -52,6 +49,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
done:
|
||||
ret = 0;
|
||||
|
||||
fail:
|
||||
|
Loading…
Reference in New Issue
Block a user