bridge: check for invalid MAC in networkGetDHCPLeases

Instead of comparing garbage strings against real MAC addresses,
introduce an error mesage for unparsable ones:

$ virsh net-dhcp-leases default  --mac t12
error: Failed to get leases info for default
error: invalid MAC address: t12

https://bugzilla.redhat.com/show_bug.cgi?id=1261432
This commit is contained in:
Ján Tomko 2015-12-03 09:47:23 +01:00
parent d2e5538b16
commit 1e6d87bdfc

View File

@ -3648,9 +3648,16 @@ networkGetDHCPLeases(virNetworkPtr network,
virNetworkDHCPLeasePtr lease = NULL;
virNetworkDHCPLeasePtr *leases_ret = NULL;
virNetworkObjPtr obj;
virMacAddr mac_addr;
virCheckFlags(0, -1);
/* only to check if the MAC is valid */
if (mac && virMacAddrParse(mac, &mac_addr) < 0) {
virReportError(VIR_ERR_INVALID_MAC, "%s", mac);
return -1;
}
if (!(obj = networkObjFromNetwork(network)))
return -1;