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.0.7~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5a49d033b63b867a744c1c4b82c9c353f3e958b;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 17bd59f24..334d55fc9 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -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); }