Commit 6168e99f by Daniel Lezcano Committed by Daniel Lezcano

fix core dump when using physical interface

If the physical link is not specified in the configuration the check in if_nametoindex(netdev->link) leads to a segfault. Check the link is specified. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com> Reported-by: 's avatarFerenc Wagner <wferi@niif.hu>
parent 7ef6e440
...@@ -1285,6 +1285,11 @@ static int instanciate_vlan(struct lxc_netdev *netdev) ...@@ -1285,6 +1285,11 @@ static int instanciate_vlan(struct lxc_netdev *netdev)
static int instanciate_phys(struct lxc_netdev *netdev) static int instanciate_phys(struct lxc_netdev *netdev)
{ {
if (!netdev->link) {
ERROR("no link specified for the physical interface");
return -1;
}
netdev->ifindex = if_nametoindex(netdev->link); netdev->ifindex = if_nametoindex(netdev->link);
if (!netdev->ifindex) { if (!netdev->ifindex) {
ERROR("failed to retrieve the index for %s", netdev->link); ERROR("failed to retrieve the index for %s", netdev->link);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment