diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index a3901d367ea7f3a791476c2bfff85a3c9b540a9f..fe4363c6d896afb446f54cf372a0d7e63fe89966 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2369,9 +2369,7 @@ virNWFilterRuleParse(xmlNodePtr node) if (virNWFilterRuleDetailsParse(cur, ret, virAttr[i].att) < 0) { - /* we ignore malformed rules - goto err_exit; - */ + goto err_exit; } break; } @@ -2572,11 +2570,13 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) { if (VIR_ALLOC(entry) < 0) 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) { diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index 5476284d7318a635fbe56b783cb5efaa10d6c7e7..84e61da1b11afa68c801d413aba74666e5ded1cb 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -36,15 +36,12 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, virResetLastError(); - if (!(dev = virNWFilterDefParseString(NULL, inXmlData))) + if (!(dev = virNWFilterDefParseString(NULL, 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))) @@ -55,6 +52,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, goto fail; } + done: ret = 0; fail: