Commit f5a49d03 by Dongsheng Yang Committed by Stéphane Graber

network: check result of if_nametoindex().

When we want to get index of a ifname which does not exist, we should return a -EINVAL in this case. Signed-off-by: 's avatarDongsheng Yang <yangds.fnst@cn.fujitsu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent c2398d17
...@@ -143,6 +143,8 @@ int lxc_netdev_move_by_name(const char *ifname, pid_t pid) ...@@ -143,6 +143,8 @@ int lxc_netdev_move_by_name(const char *ifname, pid_t pid)
return -EINVAL; return -EINVAL;
index = if_nametoindex(ifname); index = if_nametoindex(ifname);
if (!index)
return -EINVAL;
return lxc_netdev_move_by_index(index, pid); return lxc_netdev_move_by_index(index, pid);
} }
......
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