From: Dongsheng Yang Date: Thu, 11 Sep 2014 13:51:35 +0000 (+0800) Subject: network: check result of if_nametoindex(). X-Git-Tag: lxc-1.1.0.alpha3~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49428bf306f5d2e79e6030a62373a83ffbce0dea;p=thirdparty%2Flxc.git 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: Dongsheng Yang Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/network.c b/src/lxc/network.c index ce10d3180..909f3fe35 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -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); }