提交 1e6d87bd 编写于 作者: J Ján Tomko

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
上级 d2e5538b
...@@ -3648,9 +3648,16 @@ networkGetDHCPLeases(virNetworkPtr network, ...@@ -3648,9 +3648,16 @@ networkGetDHCPLeases(virNetworkPtr network,
virNetworkDHCPLeasePtr lease = NULL; virNetworkDHCPLeasePtr lease = NULL;
virNetworkDHCPLeasePtr *leases_ret = NULL; virNetworkDHCPLeasePtr *leases_ret = NULL;
virNetworkObjPtr obj; virNetworkObjPtr obj;
virMacAddr mac_addr;
virCheckFlags(0, -1); 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))) if (!(obj = networkObjFromNetwork(network)))
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册