Skip to content

Commit

Permalink
netdev: netdev_get_etheraddr is not functioning as advertised.
Browse files Browse the repository at this point in the history
netdev_get_etheraddr claims to clear 'mac' on error, but it fails to do so.
When looking further into both netdev_windows_get_etheraddr() and
netdev_linux_get_etheraddr(), 'mac' is also not cleared. This will lead to
usage of uninitialised ofputil_phy_port.hw_addr.

v1 -> v2: fixed a bug in v1 found by Ben, thanks Ben.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
yifsun authored and blp committed Nov 30, 2017
1 parent 00d12bb commit f096d79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/netdev.c
Expand Up @@ -852,7 +852,13 @@ netdev_set_etheraddr(struct netdev *netdev, const struct eth_addr mac)
int
netdev_get_etheraddr(const struct netdev *netdev, struct eth_addr *mac)
{
return netdev->netdev_class->get_etheraddr(netdev, mac);
int error;

error = netdev->netdev_class->get_etheraddr(netdev, mac);
if (error) {
memset(mac, 0, sizeof *mac);
}
return error;
}

/* Returns the name of the network device that 'netdev' represents,
Expand Down

0 comments on commit f096d79

Please sign in to comment.