From: Michal Privoznik Date: Wed, 4 Oct 2017 15:39:59 +0000 (+0200) Subject: virsh: Deal with multiple matching devices in domif-getlink X-Git-Tag: CVE-2017-1000256~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a995c6b78062be85ae03b74511e2cc7f0a08898;p=thirdparty%2Flibvirt.git virsh: Deal with multiple matching devices in domif-getlink The command tries to match interface in domain definition by MAC address or interface name. However, since it's possible to configure two interfaces with the same MAC address, it may happen that the XPath returns two or more nodes. We should check for that. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0ca53e438e..4c50155e10 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -707,13 +707,16 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (ninterfaces != 1) { + if (ninterfaces < 1) { if (macstr[0]) vshError(ctl, _("Interface (mac: %s) not found."), macstr); else vshError(ctl, _("Interface (dev: %s) not found."), iface); goto cleanup; + } else if (ninterfaces > 1) { + vshError(ctl, _("multiple matching interfaces found")); + goto cleanup; } ctxt->node = interfaces[0];