mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-30 17:45:23 +00:00
network: fix crash when portgroup has no name
This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=879473
The name attribute is required for portgroup elements (yes, the RNG
specifies that), and there is code in libvirt that assumes it is
non-null. Unfortunately, the portgroup parsing function wasn't
checking for lack of portgroup. One adverse result of this was that
attempts to update a network by adding a portgroup with no name would
cause libvirtd to segfault. For example:
virsh net-update default add portgroup "<portgroup default='yes'/>"
This patch causes virNetworkPortGroupParseXML to fail if no name is
specified, thus avoiding any later problems.
(cherry picked from commit 012d69dff1
)
This commit is contained in:
parent
3926d8571b
commit
2e7298d718
@ -1175,6 +1175,12 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
|
|||||||
|
|
||||||
/* grab raw data from XML */
|
/* grab raw data from XML */
|
||||||
def->name = virXPathString("string(./@name)", ctxt);
|
def->name = virXPathString("string(./@name)", ctxt);
|
||||||
|
if (!def->name) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("Missing required name attribute in portgroup"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
isDefault = virXPathString("string(./@default)", ctxt);
|
isDefault = virXPathString("string(./@default)", ctxt);
|
||||||
def->isDefault = isDefault && STRCASEEQ(isDefault, "yes");
|
def->isDefault = isDefault && STRCASEEQ(isDefault, "yes");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user