]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: check result of if_nametoindex().
authorDongsheng Yang <yangds.fnst@cn.fujitsu.com>
Thu, 11 Sep 2014 13:51:35 +0000 (21:51 +0800)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 15 Oct 2014 09:54:44 +0000 (11:54 +0200)
When we want to get index of a ifname which does not
exist, we should return a -EINVAL in this case.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/network.c

index ce10d318058c40e1ad629c4d0e5796d0b32fb36f..909f3fe355b383a0a4168deea37d0bd02e9c62c5 100644 (file)
@@ -144,6 +144,8 @@ int lxc_netdev_move_by_name(const char *ifname, pid_t pid)
                return -EINVAL;
 
        index = if_nametoindex(ifname);
+       if (!index)
+               return -EINVAL;
 
        return lxc_netdev_move_by_index(index, pid);
 }