]> 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)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 25 Nov 2014 21:52:00 +0000 (16:52 -0500)
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 17bd59f24d1c8dc498eca9597d73b362efad0c78..334d55fc93cba06f5b4ba4271b257884f8ae5f32 100644 (file)
@@ -143,6 +143,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);
 }