From 1e6d87bdfc801d2c006a17054bd19273430dce14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 3 Dec 2015 09:47:23 +0100 Subject: [PATCH] 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 --- src/network/bridge_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a0f64947f7..362e2945ff 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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; -- GitLab